Shuts down the write-half or both halves of the connection. This allows the socket to enter a half-closed state where it can still receive data but can no longer send data (halfClose = true
), or close both read and write (halfClose = false
, similar to end()
but potentially more immediate depending on OS). Calls shutdown(2)
syscall internally.
method
Socket.shutdown
halfClose?: boolean
): void;
@param halfClose
If true
, only shuts down the write side (allows receiving). If false
or omitted, shuts down both read and write. Defaults to false
.
// Stop sending data, but allow receiving
socket.shutdown(true);
// Shutdown both reading and writing
socket.shutdown();