xref: /freebsd/lib/libsys/shutdown.2 (revision 6580f5c38dd5b01aeeaed16b370f1a12423437f0)
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.Dd July 27, 2015
30.Dt SHUTDOWN 2
31.Os
32.Sh NAME
33.Nm shutdown
34.Nd disable sends and/or receives on a socket
35.Sh LIBRARY
36.Lb libc
37.Sh SYNOPSIS
38.In sys/types.h
39.In sys/socket.h
40.Ft int
41.Fn shutdown "int s" "int how"
42.Sh DESCRIPTION
43The
44.Fn shutdown
45system call disables sends or receives on a socket.
46The
47.Fa how
48argument specifies the type of shutdown.
49Possible values are:
50.Bl -tag -width ".Dv SHUT_RDWR"
51.It Dv SHUT_RD
52Further receives will be disallowed.
53.It Dv SHUT_WR
54Further sends will be disallowed.
55This may cause actions specific to the protocol family of the socket
56.Fa s
57to happen; see
58.Sx IMPLEMENTATION NOTES .
59.It Dv SHUT_RDWR
60Further sends and receives will be disallowed.
61Implies
62.Dv SHUT_WR .
63.El
64.Pp
65If the file descriptor
66.Fa s
67is associated with a
68.Dv SOCK_STREAM
69socket, all or part of the full-duplex connection will be shut down.
70.\"
71.Sh IMPLEMENTATION NOTES
72The following protocol specific actions apply to the use of
73.Dv SHUT_WR
74(and potentially also
75.Dv SHUT_RDWR ) ,
76based on the properties of the socket associated with the file descriptor
77.Fa s .
78.Bl -column ".Dv PF_INET6" ".Dv SOCK_STREAM" ".Dv IPPROTO_SCTP"
79.It Sy Domain Ta Sy Type Ta Sy Protocol Ta Sy Action
80.It Dv PF_INET Ta Dv SOCK_DGRAM Ta Dv IPPROTO_SCTP Ta
81Failure,
82as socket is not connected.
83.It Dv PF_INET Ta Dv SOCK_DGRAM Ta Dv IPPROTO_UDP Ta
84Failure,
85as socket is not connected.
86.It Dv PF_INET Ta Dv SOCK_STREAM Ta Dv IPPROTO_SCTP Ta
87Send queued data and tear down association.
88.It Dv PF_INET Ta Dv SOCK_STREAM Ta Dv IPPROTO_TCP Ta
89Send queued data, wait for ACK, then send FIN.
90.It Dv PF_INET6 Ta Dv SOCK_DGRAM Ta Dv IPPROTO_SCTP Ta
91Failure,
92as socket is not connected.
93.It Dv PF_INET6 Ta Dv SOCK_DGRAM Ta Dv IPPROTO_UDP Ta
94Failure,
95as socket is not connected.
96.It Dv PF_INET6 Ta Dv SOCK_STREAM Ta Dv IPPROTO_SCTP Ta
97Send queued data and tear down association.
98.It Dv PF_INET6 Ta Dv SOCK_STREAM Ta Dv IPPROTO_TCP Ta
99Send queued data, wait for ACK, then send FIN.
100.El
101.\"
102.Sh RETURN VALUES
103.Rv -std shutdown
104.Sh ERRORS
105The
106.Fn shutdown
107system call fails if:
108.Bl -tag -width Er
109.It Bq Er EBADF
110The
111.Fa s
112argument is not a valid file descriptor.
113.It Bq Er EINVAL
114The
115.Fa how
116argument is invalid.
117.It Bq Er ENOTCONN
118The
119.Fa s
120argument specifies a socket which is not connected.
121.It Bq Er ENOTSOCK
122The
123.Fa s
124argument does not refer to a socket.
125.El
126.Sh SEE ALSO
127.Xr connect 2 ,
128.Xr socket 2 ,
129.Xr inet 4 ,
130.Xr inet6 4
131.Sh STANDARDS
132The
133.Fn shutdown
134system call is expected to comply with
135.St -p1003.1g-2000 ,
136when finalized.
137.Sh HISTORY
138The
139.Fn shutdown
140system call appeared in
141.Bx 4.2 .
142The
143.Dv SHUT_RD , SHUT_WR ,
144and
145.Dv SHUT_RDWR
146constants appeared in
147.St -p1003.1g-2000 .
148.Sh AUTHORS
149.An -nosplit
150This manual page was updated by
151.An Bruce M. Simpson Aq Mt bms@FreeBSD.org
152to reflect how
153.Fn shutdown
154behaves with
155.Dv PF_INET
156and
157.Dv PF_INET6
158sockets.
159.Sh BUGS
160The ICMP
161.Dq Li "port unreachable"
162message should be generated in response to
163datagrams received on a local port to which
164.Fa s
165is bound
166after
167.Fn shutdown
168is called.
169