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