How should I determine what to use for a listening socket's backlog parameter? Is it a problem to simply specify a very large number?
How should I determine what to use for a listening socket's backlog parameter? Is it a problem to simply specify a very large number?
There's a very long answer to this in the Winsock Programmer's FAQ. It details the standard setting, and the dynamic backlog feature added in a hotfix to NT 4.0.
I second using SOMAXCONN, unless you have a specific reason to use a short queue.
Keep in mind that if there is no room in the queue for a new connection, no RST will be sent, allowing the client to automatically continue trying to connect by retransmitting SYN.
Also, the backlog argument can have different meanings in different socket implementations.
From the docs:
A value for the backlog of SOMAXCONN is a special constant that instructs the underlying service provider responsible for socket s to set the length of the queue of pending connections to a maximum reasonable value.