| SHUTDOWN(2) | System Calls Manual | SHUTDOWN(2) |
shutdown — disable
sends or receives on a socket
#include
<sys/socket.h>
int
shutdown(int
s, int how);
The
shutdown()
system call disables sends or receives on a socket.
If the file descriptor s is associated with
a SOCK_STREAM socket, all or part of the full-duplex
connection will be shut down.
The how argument specifies the type of shutdown. Possible values are:
The following protocol specific actions apply to the use of
SHUT_WR based on the properties of the socket
associated with the file descriptor s:
| DOMAIN | TYPE | PROTOCOL | RETURN VALUE AND ACTION |
AF_INET |
SOCK_DGRAM |
IPPROTO_UDP |
Return 0. ICMP messages will not be generated. |
AF_INET |
SOCK_STREAM |
IPPROTO_TCP |
Return 0. Send queued data, wait for ACK, then send FIN. |
AF_INET6 |
SOCK_DGRAM |
IPPROTO_UDP |
Return 0. ICMP messages will not be generated. |
AF_INET6 |
SOCK_STREAM |
IPPROTO_TCP |
Return 0. Send queued data, wait for ACK, then send FIN. |
Upon successful completion, the value 0 is returned; otherwise the value -1 is returned and the global variable errno is set to indicate the error.
The shutdown() system call fails if:
EBADF]EINVAL]ENOTCONN]SOCK_STREAM socket which is not connected.ENOTSOCK]EOPNOTSUPP]The shutdown() function conforms to
IEEE Std 1003.1-2008 (“POSIX.1”).
The shutdown() system call first appeared
in 4.1cBSD. The SHUT_RD,
SHUT_WR, and SHUT_RDWR
constants appeared in IEEE Std 1003.1g-2000
(“POSIX.1g”).
The ICMP “port unreachable” message should be
generated in response to datagrams received on a local port to which
s is bound after shutdown() is
called.
| September 9, 2014 | openbsd |