So, I make the basic server and client program in C, and after starting the program, the result is a really strange named file, which I have to delete in order for the program to work again. I assume that I am not closing sockets correctly. I am currently closing sockets as follows:
shutdown(serverSocket, SHUT_RDWR);
shutdown(clientSocket, SHUT_RDWR);
Any idea on why this is happening?
Edit: both of these functions return 0
Here is the code causing the problem:
char buf[1024];
struct sockaddr_in server, client;
int serverSocket = socket(PF_LOCAL, SOCK_STREAM, 0);
server.sin_family = AF_LOCAL;
server.sin_port = htons(54164);
server.sin_addr.s_addr = inet_addr("127.0.0.1");
bind(serverSocket, (struct sockaddr *) &server, sizeof(server));
The file does not appear until I ran the bind function.
source
share