Is there a difference between
shutdown($socket, 0) if $socket;
shutdown($socket, 2) if $socket;
close($socket) if $socket;
and
shutdown($socket, 2) if $socket;
close($socket) if $socket;
Also is there a difference between
shutdown($socket, 1) if $socket;
shutdown($socket, 2) if $socket;
close($socket) if $socket;
and
shutdown($socket, 2) if $socket;
close($socket) if $socket;
And finally is the close
needed at all?
shutdown
causes one side of the TCP connection to stop reading (0
), or writing (1
), or both (2
). So the first two snippets have the same effect, as do the next two.
shutdown
does not release the file descriptor, so close
is still needed.
The difference between single close
and one preceded by shutdown( fd, 2 )
is that in the second case TCP will not try to deliver outstanding data to the remote side (see SO_LINGER
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With