Connection Backlog

Hi. I just got my 7520 development kit and am playing around with writing my own applications. I need to create an application that accepts only one TCP connection at a time. I call listen() with a “backlog” of zero ( listen(sock, 0) ) so that it will accept only one connection. However, it will accept two connections and only processes data from one of them. This isn’t entirely unacceptable since the application won’t process any data from the second connection, but ideally the application should reject the second connection. Any help would be greatly appreciated. --Cameron

The socket call listen has two arguments int listen(int s, int backlog), s is the local socket and backlog is the maximum length of the queue of pending connections - I think this what you are looking for since this is also called packet queue depth. According to W. Richard Stevens UNIX Network Programming the MAXIMUM actual number of queued connections for particular values of backlog are as follows: Backlog number Max Connections 0 1 - 2 1 2 - 3 5 7 - 9 Since our stack is fully complaint with Berkeley sockets now you can see where the recommendation comes from. Different implementations interpret backlog of 0 differently. Some implementations allow one queued connection, while others do not allow any queued connections. If you do not want any clients connecting to your listening socket, then close the listening socket.

Ok, that makes sense. Thanks.