1

Why doesn't accept() block?

view story
linux-howto

http://stackoverflow.com – I'm new in socket programming under Linux (UNIX) sockets. I found the following code in the Internet, for a tcp-server that spawns a thread for each connection. However it doesn't work. the accept() function returns instantly, and doesn't wait for connection. What am I doing wrong ? this is the code int main(int argv, char *args[]) { struct sockaddr_in addr; int sd, port; port = htons(SERVER_PORT); /*--- create socket ---*/ sd = socket(PF_INET, SOCK_STREAM, 0); if ( sd < 0 ) panic("socket"); /*--- bind port/address to socket ---*/ memset(&add (HowTos)