Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

shutdown(2) [freebsd man page]

SHUTDOWN(2)						      BSD System Calls Manual						       SHUTDOWN(2)

NAME
shutdown -- disable sends and/or receives on a socket LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/types.h> #include <sys/socket.h> int shutdown(int s, int how); DESCRIPTION
The shutdown() system call disables sends or receives on a socket. The how argument specifies the type of shutdown. Possible values are: SHUT_RD Further receives will be disallowed. SHUT_WR Further sends will be disallowed. This may cause actions specific to the protocol family of the socket s to happen; see IMPLEMENTATION NOTES. SHUT_RDWR Further sends and receives will be disallowed. Implies SHUT_WR. If the file descriptor s is associated with a SOCK_STREAM socket, all or part of the full-duplex connection will be shut down. IMPLEMENTATION NOTES
The following protocol specific actions apply to the use of SHUT_WR (and potentially also SHUT_RDWR), based on the properties of the socket associated with the file descriptor s. Domain Type Protocol Return value and action PF_INET SOCK_DGRAM IPPROTO_SCTP Return -1. The global variable errno will be set to EOPNOTSUPP. PF_INET SOCK_DGRAM IPPROTO_UDP Return 0. ICMP messages will not be generated. PF_INET SOCK_STREAM IPPROTO_SCTP Return 0. Send queued data and tear down association. PF_INET SOCK_STREAM IPPROTO_TCP Return 0. Send queued data, wait for ACK, then send FIN. PF_INET6 SOCK_DGRAM IPPROTO_SCTP Return -1. The global variable errno will be set to EOPNOTSUPP. PF_INET6 SOCK_DGRAM IPPROTO_UDP Return 0. ICMP messages will not be generated. PF_INET6 SOCK_STREAM IPPROTO_SCTP Return 0. Send queued data and tear down association. PF_INET6 SOCK_STREAM IPPROTO_TCP Return 0. Send queued data, wait for ACK, then send FIN. RETURN VALUES
The shutdown() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indi- cate the error. ERRORS
The shutdown() system call fails if: [EBADF] The s argument is not a valid file descriptor. [EINVAL] The how argument is invalid. [EOPNOTSUPP] The socket associated with the file descriptor s does not support this operation. [ENOTCONN] The s argument specifies a SOCK_STREAM socket which is not connected. [ENOTSOCK] The s argument does not refer to a socket. SEE ALSO
connect(2), socket(2), inet(4), inet6(4) STANDARDS
The shutdown() system call is expected to comply with IEEE Std 1003.1g-2000 (``POSIX.1''), when finalized. HISTORY
The shutdown() system call appeared in 4.2BSD. The SHUT_RD, SHUT_WR, and SHUT_RDWR constants appeared in IEEE Std 1003.1g-2000 (``POSIX.1''). AUTHORS
This manual page was updated by Bruce M. Simpson <bms@FreeBSD.org> to reflect how shutdown() behaves with PF_INET and PF_INET6 sockets. BUGS
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. BSD
March 5, 2007 BSD

Check Out this Related Man Page

SHUTDOWN(P)						     POSIX Programmer's Manual						       SHUTDOWN(P)

NAME
shutdown - shut down socket send and receive operations SYNOPSIS
#include <sys/socket.h> int shutdown(int socket, int how); DESCRIPTION
The shutdown() function shall cause all or part of a full-duplex connection on the socket associated with the file descriptor socket to be shut down. The shutdown() function takes the following arguments: socket Specifies the file descriptor of the socket. how Specifies the type of shutdown. The values are as follows: SHUT_RD Disables further receive operations. SHUT_WR Disables further send operations. SHUT_RDWR Disables further send and receive operations. The shutdown() function disables subsequent send and/or receive operations on a socket, depending on the value of the how argument. RETURN VALUE
Upon successful completion, shutdown() shall return 0; otherwise, -1 shall be returned and errno set to indicate the error. ERRORS
The shutdown() function shall fail if: EBADF The socket argument is not a valid file descriptor. EINVAL The how argument is invalid. ENOTCONN The socket is not connected. ENOTSOCK The socket argument does not refer to a socket. The shutdown() function may fail if: ENOBUFS Insufficient resources were available in the system to perform the operation. The following sections are informative. EXAMPLES
None. APPLICATION USAGE
None. RATIONALE
None. FUTURE DIRECTIONS
None. SEE ALSO
getsockopt() , read() , recv() , recvfrom() , recvmsg() , select() , send() , sendto() , setsockopt() , socket() , write() , the Base Defi- nitions volume of IEEE Std 1003.1-2001, <sys/socket.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 SHUTDOWN(P)
Man Page