tcp - Linux: socket close() vs shutdown() -
so on linux, shutdown() can take parameter shut_rd, shut_wr or shut_rdwr shutdown part of communication channel. in terms of tcp messages sending peer, how work?
in tcp state machine, closing works in 4-way handshake fashion,
(1) (2) fin----------> <----------ack <----------fin ack-----------> so messages dose send when shutdown(sock, shut_rd) or shutdown(sock, shut_wr)?
shutdown(sd, shut_wr) sends fin peer responds ack. farther attempts write socket incur error. peer can still go on send data.
shutdown(sd, shut_rd) sends nil on network: conditions local api homecoming eos subsequent reads on socket. behaviour when receiving info on socket has been shutdown read system-dependent: unix ack , throw away; linux ack , buffer it, stall sender; windows issue rst, sender sees 'connection reset peer'.
linux tcp
No comments:
Post a Comment