views:

85

answers:

1

Hi,

I have both TCP client and TCP server run on RHEL 5.3 on different machines.

  • I'm killing server and FIN is sent to the client. ACK is sent back by client's OS back immediately.

  • Client discovers the close (by read() returning zero) and perfroms close only after 90 sec. At this stage I verified netstat on both sides and it's as expected (FIN_WAIT_2 on server and CLOSE_WAIT on client).

  • Due client close() after 90 sec, client's OS sends FIN to server, but in response we receive RST from server and not ACK as expected.

I also saw several times that due to "delayed" close(), client's OS sent RST instead of FIN.

Please note, that in both cases there's no pending reading packets on both sides and SO_LINGER option is not activated.

Any ideas?

+3  A: 

The RST indicates that some "data" was lost. In this case, the "data" is the information that the client side closed the socket cleanly - the FIN from the client was not reported to the server side application (because it had been killed).

In other words, the RST tells the client that the server never saw end-of-stream from the client.

caf
Thanks! And what can lead to RST be sent by client upon "delayed" close()? I faced the problem too.
dimba
@idimba: Probably means that the client never saw the end-of-connection either (a `recv()` returning 0).
caf