“Operating System Tech Support” <email@example.com> wrote in message
“Johannes” <> firstname.lastname@example.org> > wrote in message
news:9tgjpo$nrt$> email@example.com> …
Though the process has terminated, its socket connection remains in
which is noticeable in netstat -a which shows the connection state in
Wait. Due to this “unclosed” connection, the process cannot be restarted
because it cannot reuse the address. I have two choices, which is either
wait until TCP/IP timeout and close the connection (which takes about 30
minutes), or slay Socket process.
This is a very frequent question in TCP/IP programming across the board.
You need to use the setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &sockopt,
sockopt_len) call so that you can rebind to the port.
this is a standard solluion noted at “Advansed Sockets Programming” chapter
of tcp/tk documentation it works for sure but as a part of the problem
i’v saw quite strange tcpip stack’s behaviour: even when socket no more
exists i.e. was closed by calling process, depending on remote peer socket
state connection record obtained with “netstat -a” still pending in
CLOSE_WAIT state. it’s ok, but sometimes when remote peer also closes its
socket it still exists and this time forever i.e. can be cleaned up only
after Tcpip stack restart. now imagine some situation, when clients are
connecting/disconnecting for example several times per minute this strange
way and what happens with stack itself after several hours of alike
i saw it with Tcpip v5.0X and [not sure] latest Socket 4.25. afair source
code with help of which i saw this stack overflow is avaialbe.