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