Hi,
I've inherited some code in C that acts as a server and receives requests over a socket. That is all working fine. I wanted to make a very small change to the server code to print out the hostname of the client connection. However, I'm always getting 0.0.0.0 as the answer...
struct sockaddr_in mysocket;
int length;
if ((s = accept(ls, (struct sockaddr *) &mysocket, &length)) < 0) {
perror("accept()");
exit(1);
}
printf ( "Connection received from: %s\n", inet_ntoa(mysocket.sin_addr));
Connection received from: 0.0.0.0
Any idea what I'm doing wrong?