Disconnect() does not return TIMEOUT error

Hello.

Consider the following scenario:

  1. TCP, client vs server
  2. client sends disconnect to server (FIN)
  3. server replies with ACK

till here it OK

  1. server is stuck for some reason (simulated by a breakpoint in the server app)
  2. server does not send FIN to client (as supposed)
  3. client never changes its socket to close (as it hasn’t received a FIN from the server)
  4. client’s socket is in FIN_WAIT (= 0x18) state
  5. client is stuck in an infinite loop in the disconnect() func
    |
    |
    V

Can you please help fixing the bug?

Thanks,
Aviv

Hi, avivf!

You have a similar problem on [url]SOCK_FIN_WAIT, SnRX_RSR transient issues].

Refer to it.

thank you.

Hello,
I’ve been reading your reply. You mentioned that in a server application it’s better to use close() rather than disconnect().

  1. What if my application in a client instead of a server. Should I still use close() rather than disconnet()?
  2. What is the actual difference between close() and disconnet()? When disconnet() is to be used?

Thanks,
Aviv

The disconnection process involves communication with the peer with ACK / FIN exchanges and can be Active or Passive ( depends on connected peer ). In any case, at the end of the disconnection, the status Sn_SR always passes in SOCK_CLOSED and it is quite hard to find SOCK_CLOSING, SOCK_FIN_WAIT or SOCK_LAST_ACK for the speed with which move from one state to another.
I noticed that in LAN is very difficult to read these intermediate states and if you wait a disconnect you get lost forever in an intermediate state while if you connect through internet is quite repeatable.

Hello,
I’ve been reading your reply. You mentioned that in a server application it’s better to use close() rather than disconnect().

  1. What if my application in a client instead of a server. Should I still use close() rather than disconnet()?
  2. What is the actual difference between close() and disconnet()? When disconnet() is to be used?

Thanks,
Aviv

In client or server application the problem remains…

  • In a communication with an http server where once you’ve sent the request and received the answer instead of making a DISCONNECT for as mentioned above should make a CLOSE to prevent the ACK / FIN that in any case occur even in this case.
  • In case of communications with continuous flow at the end does not make DISCONNECT but simply make a CLOSE.

Hi,
It is upto you what is used close() or disconnect(). If you want to be safe closed the channel, You’d like to use close(). And if you don’t need to be safe closed the channel.

The difference close() from disconnect(),
While disconnect() requests the peer to close the channel, close() is not request the the close the channel.

In disconnect() processing is as following
NodeA NodeB
FIN------------>
<----------ACK
<----------FIN
ACK----------->

In close() processing is no need FIN & ACK packets. So, Just only own the channel is closed, The peer’s channel is still connected.

Thank you.