Hello,
I'm devloping a Linux socket application and having some problems. I'd
appreciate any help that anyone could give on these issues:
1. I'm opening and closing TCP sockets at a high rate (500-1000
connections per second). Connections seem to be staying in CLOSE_WAIT
and TIMEOUT_WAIT state for a long time. I am using the following
(pseudo)code to close the socket:
shutdown(socket,1)
while (recv(socket,...)>0) ;
close(socket)
I've also tried some code out of Apache web server that includes a
select() call in the recv() while loop to check for incoming data. No
difference.
2. Sometimes my program deadlocks, apparently inside of a socket call.
"ps -al" reports that it's stuck in tcp_getsocket. Netstat reports that
a large number of sockets are stuck in CLOSE_WAIT (or TIMEOUT_WAIT) and
they won't go away until I kill the process.
3. Most of the above problems start happening when I run the program at
near the limit of how many sockets it can process (and/or beyond what it
can handle)
4. Sometimes the client side of the connection gets a Connection_Refused
error. (This might be expected if the server is exceeding the listen
queue size)
I'm currently running under Red Hat 4.1. Will be upgrading to 5.0 in a
few weeks. The ethernet in use is 100mbs switched. I'd appreciate any
if possible.
--