Closed sockets remains in CLOSE WAIT for long time

Hi,

In my application, some sockets remain in close wait state for long time in server side. I checked applying debug prints and found that we are closing the sokects using closesocket() method. The closesocket method returns 0 after closing the socket.

But when we nestat - we still see the closed socket in the close wait state.

We added shutdown socket method (before closesocket) still no success. Any help regarding this is appreciated ..

Regards,
Sri.
Speaking from a UNIX standpoint (yes I know this is the Windows forum), this is deliberate.
I believe you can avoid that by using the REUSEADDR socket option.

(The kernel keeps the address "in use" for a while after you've closed the socket in the event
that the peer continues to send data to that address for a time after you've closed the socket.
If another app were to reuse the address immediately, it might erroneously receive that stale
data).
Topic archived. No new replies allowed.