close
VS shutdown
stackoverflow close vs shutdown socket?
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).