Consider a TCP connection established between two TCP endpoints, where one of them calls either:
close()
: Here, no further read or write is permitted.shutdown(fd, SHUT_WR)
: This converts the full duplex connection to simplex, where the endpoint invokingSHUT_WR
can still read.
However, in both the cases a FIN packet is sent on the wire to the peer endpoint. So the question is, how can the TCP endpoint which receives the FIN distinguish whether the other endpoint has used close()
or SHUT_WR
, since in the latter scenario it should still be able to send data?