1.\" Copyright (c) 2007 Bruce M. Simpson. 2.\" Copyright (c) 1983, 1991, 1993 3.\" The Regents of the University of California. All rights reserved. 4.\" 5.\" Redistribution and use in source and binary forms, with or without 6.\" modification, are permitted provided that the following conditions 7.\" are met: 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 3. Neither the name of the University nor the names of its contributors 14.\" may be used to endorse or promote products derived from this software 15.\" without specific prior written permission. 16.\" 17.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" SUCH DAMAGE. 28.\" 29.\" @(#)shutdown.2 8.1 (Berkeley) 6/4/93 30.\" 31.Dd July 27, 2015 32.Dt SHUTDOWN 2 33.Os 34.Sh NAME 35.Nm shutdown 36.Nd disable sends and/or receives on a socket 37.Sh LIBRARY 38.Lb libc 39.Sh SYNOPSIS 40.In sys/types.h 41.In sys/socket.h 42.Ft int 43.Fn shutdown "int s" "int how" 44.Sh DESCRIPTION 45The 46.Fn shutdown 47system call disables sends or receives on a socket. 48The 49.Fa how 50argument specifies the type of shutdown. 51Possible values are: 52.Bl -tag -width ".Dv SHUT_RDWR" 53.It Dv SHUT_RD 54Further receives will be disallowed. 55.It Dv SHUT_WR 56Further sends will be disallowed. 57This may cause actions specific to the protocol family of the socket 58.Fa s 59to happen; see 60.Sx IMPLEMENTATION NOTES . 61.It Dv SHUT_RDWR 62Further sends and receives will be disallowed. 63Implies 64.Dv SHUT_WR . 65.El 66.Pp 67If the file descriptor 68.Fa s 69is associated with a 70.Dv SOCK_STREAM 71socket, all or part of the full-duplex connection will be shut down. 72.\" 73.Sh IMPLEMENTATION NOTES 74The following protocol specific actions apply to the use of 75.Dv SHUT_WR 76(and potentially also 77.Dv SHUT_RDWR ) , 78based on the properties of the socket associated with the file descriptor 79.Fa s . 80.Bl -column ".Dv PF_INET6" ".Dv SOCK_STREAM" ".Dv IPPROTO_SCTP" 81.It Sy Domain Ta Sy Type Ta Sy Protocol Ta Sy Action 82.It Dv PF_INET Ta Dv SOCK_DGRAM Ta Dv IPPROTO_SCTP Ta 83Failure, 84as socket is not connected. 85.It Dv PF_INET Ta Dv SOCK_DGRAM Ta Dv IPPROTO_UDP Ta 86Failure, 87as socket is not connected. 88.It Dv PF_INET Ta Dv SOCK_STREAM Ta Dv IPPROTO_SCTP Ta 89Send queued data and tear down association. 90.It Dv PF_INET Ta Dv SOCK_STREAM Ta Dv IPPROTO_TCP Ta 91Send queued data, wait for ACK, then send FIN. 92.It Dv PF_INET6 Ta Dv SOCK_DGRAM Ta Dv IPPROTO_SCTP Ta 93Failure, 94as socket is not connected. 95.It Dv PF_INET6 Ta Dv SOCK_DGRAM Ta Dv IPPROTO_UDP Ta 96Failure, 97as socket is not connected. 98.It Dv PF_INET6 Ta Dv SOCK_STREAM Ta Dv IPPROTO_SCTP Ta 99Send queued data and tear down association. 100.It Dv PF_INET6 Ta Dv SOCK_STREAM Ta Dv IPPROTO_TCP Ta 101Send queued data, wait for ACK, then send FIN. 102.El 103.\" 104.Sh RETURN VALUES 105.Rv -std shutdown 106.Sh ERRORS 107The 108.Fn shutdown 109system call fails if: 110.Bl -tag -width Er 111.It Bq Er EBADF 112The 113.Fa s 114argument is not a valid file descriptor. 115.It Bq Er EINVAL 116The 117.Fa how 118argument is invalid. 119.It Bq Er ENOTCONN 120The 121.Fa s 122argument specifies a socket which is not connected. 123.It Bq Er ENOTSOCK 124The 125.Fa s 126argument does not refer to a socket. 127.El 128.Sh SEE ALSO 129.Xr connect 2 , 130.Xr socket 2 , 131.Xr inet 4 , 132.Xr inet6 4 133.Sh STANDARDS 134The 135.Fn shutdown 136system call is expected to comply with 137.St -p1003.1g-2000 , 138when finalized. 139.Sh HISTORY 140The 141.Fn shutdown 142system call appeared in 143.Bx 4.2 . 144The 145.Dv SHUT_RD , SHUT_WR , 146and 147.Dv SHUT_RDWR 148constants appeared in 149.St -p1003.1g-2000 . 150.Sh AUTHORS 151.An -nosplit 152This manual page was updated by 153.An Bruce M. Simpson Aq Mt [email protected] 154to reflect how 155.Fn shutdown 156behaves with 157.Dv PF_INET 158and 159.Dv PF_INET6 160sockets. 161.Sh BUGS 162The ICMP 163.Dq Li "port unreachable" 164message should be generated in response to 165datagrams received on a local port to which 166.Fa s 167is bound 168after 169.Fn shutdown 170is called. 171