Im not worried about the warnings or notes. What I would like to know is what would cause this kind of fatal error? Line number 48 it says.
Code:
ubuntu@ubuntu:~/Documents$ gcc server.c -o server
server.c: In function ‘main’:
server.c:38: warning: passing argument 3 of ‘accept’ makes pointer from integer without a cast
/usr/include/sys/socket.h:214: note: expected ‘socklen_t * __restrict__’ but argument is of type ‘unsigned int’
server.c: At top level:
server.c:48: fatal error: error closing /tmp/ccE99bS8.s: No space left on device
compilation terminated.
ubuntu@ubuntu:~/Documents$
I have been coding a basic server twice a day for 2 weeks and have never had a problem till now for some odd reason. but heres the code just in case
Code:
/*A simple TCP server for linux*/
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
int main(int argc, char *argv[]) {
int sockfd, newsockfd, portno;
char buffer[256];
struct sockaddr_in serv_addr, cli_addr;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if(sockfd < 0) fprintf(stderr, "Error creating socket.");
bzero((char *) &serv_addr, sizeof(serv_addr));
portno = atoi(argv[1]);
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = INADDR_ANY;
serv_addr.sin_port = htons(portno);
if(bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
fprintf(stderr, "Error binding to socket.");
listen(sockfd, 5);
newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, sizeof(cli_addr));
if(newsockfd < 0) fprintf(stderr, "Error accepting new connection.");
for( ; ; ) {
}
close(newsockfd);
close(sockfd);
return 0;
}