Can anyone give me some information on how a Linux server task should
properly close it's socket connection(s) when it is terminated so that
open socket connections are not left in FIN_WAIT or FIN_WAIT_2 state?
Currently .. if my server task is running and has an open socket
connection to a client, and the server task is terminated, then the
socket connection will go to FIN_WAIT_2 state and then the server
task can not be restarted until these connections finally time out and
close (bind fail on port in use) .. which may take several minutes.
This happens even if the socket is not currently transferring any data.
I have tried using various combinations of shutdown() and close()
when the server detects a SIGTERM but they do not work reliably.. in
particular for NT clients.
This is for AF_INET SOCK_STREAM type sockets.. if it matters.
Any information or references to some good books that cover socket
programming would be appreciated.
Pete Rossi - WA3NNA