in reply to CLOSE-WAIT sockets

Simon,

You didn't mention the operating system under which your code is running. If it's Solaris, you can tweak the time_wait interval with ndd (add it to an /etc/init.d script if you'd like) like this:

ndd set /dev/tcp tcp_time_wait_interval 30000

Where 30000 is the interval in milliseconds. Everything I've read seems to show this as the bare minimum you can get away with without generating problems. If you need a few more filehandles, you can set that with plimit:

plimit -n 4096,1024 $PID

where $PID is the process id of your parent. Or, you can add this to /etc/system (and reboot) to affect all processes:

rlim_fd_max=4096
rlim_fd_cur=1024


Check out the Tunable TCP/IP Parameters section or the General I/O section of the Tunable Parameters Reference Manual for more info. While neither of these will close your socket, it'll give you a bit more overhead so that your sockets will time out on their own without causing you grief. Best of luck.

-beernuts

Edit (4/1) - removed redundant 'Reference Manual' text