This is explained in Beej's networking guide. shutdown
is a flexible way to block communication in one or both directions. When the second parameter is SHUT_RDWR
, it will block both sending and receiving (like close
). However, close
is the way to actually destroy a socket.
With shutdown
, you will still be able to receive pending data the peer already sent (thanks to Joey Adams for noting this).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…