C : non blocking sockets with timeout : how to check if connection request was made?
问题 I would like to have a server that connects to one client at a time, ignoring connection request when connected to a given client. I would also liked to avoid the server to get locked when listening for the first client, so that the program can be terminated cleanly. Apparently, sockets can be made non blocking: http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html#blocking I created my socket accordingly (error management code removed for clarity) int sockfd; struct sockaddr_in self;