CLOSE_WAIT state on sockets during high volume



Hi,

I have a client/server application running and communicating using IP
sockets. During high volume traffic many of the client sockets are
stuck in a CLOSE_WAIT state (as determined by lsof). Eventually I
reach my max open file limit and this causes all sorts of other
problems forcing me to restart the application. Googling this problem
revealed that it could be caused if the client is not closing the
connection after it receives a FIN from the server. However, this does
not make sense to me since every connection takes the same path through
the code and the problem only surfaces when there is a high volume of
connections. My server waits for connections, spawns a thread for each
request and sends the socket file descriptor as a parameter to the
thread. This problem does not occur during times of low volume.

Thanks

.