I’m trying to implement a communication between a legacy system and a Linux system but I constantly get one of the following scenarios:
(The legacy system is server, the Linux is client)
Function recv(2) returns 0 (the peer has performed an orderly shutdown.)
> SYN
< SYN, ACK
> ACK
< PSH, ACK (the data)
> FIN, ACK
< ACK
> RST
< FIN, ACK
> RST
> RST
Function connect(2) returns -1 (error)
> SYN
< RST, ACK
When the server have send its data, the client should answer with data, but instead I get a “FIN, ACK”
Why is it like this? How should I interpret this? I’m not that familiar with TCP at this level
It could be that once the server has sent the data (line 4) the client closes the socket or terminates prematurely and the operating system closes its socket and sends
FIN(line 5). The server replies toFINwithACKbut the client has ceased to exist already and its operating system responds withRST. (I would expect the client OS to silently ignore and discard any TCP segments arriving for a closed connection during the notoriousTIME-WAITstate, but that doesn’t happen for some reason.)http://en.wikipedia.org/wiki/Transmission_Control_Protocol#Connection_termination: