Debian Codegraph @

upstream/debian-unstable/man2/shutdown.2

raw
1 .\" Copyright 1983-1991, The Regents of the University of California.
2 .\" Copyright, the authors of the Linux man-pages project
3 .\"
4 .\" SPDX-License-Identifier: BSD-4-Clause-UC
5 .\"
6 .TH shutdown 2 2025-10-29 "Linux man-pages 6.18"
7 .SH NAME
8 shutdown \- shut down part of a full-duplex connection
9 .SH LIBRARY
10 Standard C library
11 .RI ( libc ,\~ \-lc )
12 .SH SYNOPSIS
13 .nf
14 .B #include <sys/socket.h>
15 .P
16 .BI "int shutdown(int " sockfd ", int " how );
17 .fi
18 .SH DESCRIPTION
19 The
20 .BR shutdown ()
21 call causes all or part of a full-duplex connection on the socket
22 associated with
23 .I sockfd
24 to be shut down.
25 If
26 .I how
27 is
28 .BR SHUT_RD ,
29 further receptions will be disallowed.
30 If
31 .I how
32 is
33 .BR SHUT_WR ,
34 further transmissions will be disallowed.
35 If
36 .I how
37 is
38 .BR SHUT_RDWR ,
39 further receptions and transmissions will be disallowed.
40 .SH RETURN VALUE
41 On success, zero is returned.
42 On error, \-1 is returned, and
43 .I errno
44 is set to indicate the error.
45 .SH ERRORS
46 .TP
47 .B EBADF
48 .I sockfd
49 is not a valid file descriptor.
50 .TP
51 .B EINVAL
52 An invalid value was specified in
53 .I how
54 (but see BUGS).
55 .TP
56 .B ENOTCONN
57 The specified socket is not connected.
58 .TP
59 .B ENOTSOCK
60 The file descriptor
61 .I sockfd
62 does not refer to a socket.
63 .SH STANDARDS
64 POSIX.1-2024.
65 .SH HISTORY
66 POSIX.1-2001, 4.4BSD
67 (first appeared in 4.2BSD).
68 .SH NOTES
69 The constants
70 .BR SHUT_RD ,
71 .BR SHUT_WR ,
72 .B SHUT_RDWR
73 have the value 0, 1, 2,
74 respectively, and are defined in
75 .I <sys/socket.h>
76 since glibc-2.1.91.
77 .SH BUGS
78 Checks for the validity of
79 .I how
80 are done in domain-specific code,
81 and before Linux 3.7 not all domains performed these checks.
82 .\" https://bugzilla.kernel.org/show_bug.cgi?id=47111
83 Most notably, UNIX domain sockets simply ignored invalid values.
84 This problem was fixed for UNIX domain sockets
85 .\" commit fc61b928dc4d72176cf4bd4d30bf1d22e599aefc
86 .\" and for DECnet sockets in commit 46b66d7077b89fb4917ceef19b3f7dd86055c94a
87 in Linux 3.7.
88 .SH SEE ALSO
89 .BR close (2),
90 .BR connect (2),
91 .BR socket (2),
92 .BR socket (7)