SHUTDOWN(2)
β¨ shutdown(2) β¨
okay so bestie, welcome to shutdown(2) β the System Calls Manual page you didn't know you needed π
no cap.
πΈ NAME πΈ
shutdown β disable sends and/or receives on a socket π«π€π₯
π LIBRARY π
Standard C Library (libc, -lc) π«Ά
β¨ SYNOPSIS β¨
#include <sys/types.h>
#include <sys/socket.h>
int
shutdown(int s, int how);
π DESCRIPTION π
The shutdown() system call disables sends or receives on a socket. Like, it's giving "we're done here" energy to one direction or both π
The how argument specifies the type of shutdown. Possible values are:
SHUT_RDβ further receives will be disallowed. bye bye incoming data πSHUT_WRβ further sends will be disallowed. This may cause actions specific to the protocol family of the socketsto happen; see βIMPLEMENTATION NOTESβ. lowkey this one has side quests πSHUT_RDWRβ further sends and receives will be disallowed. ImpliesSHUT_WR. both directions? gone. periodt.
If the file descriptor s is associated with a SOCK_STREAM socket, all or part of the full-duplex connection will be shut down. iconic behavior honestly π
π§ IMPLEMENTATION NOTES π§
The following protocol specific actions apply to the use of SHUT_WR (and potentially also SHUT_RDWR), based on the properties of the socket associated with the file descriptor s.
Like, the vibe check depends on your domain + type + protocol combo, so here's the whole roster π¦:
- Domain
PF_INET, TypeSOCK_DGRAM, ProtocolIPPROTO_SCTPβ failure, as socket is not connected. π - Domain
PF_INET, TypeSOCK_DGRAM, ProtocolIPPROTO_UDPβ failure, as socket is not connected. π - Domain
PF_INET, TypeSOCK_STREAM, ProtocolIPPROTO_SCTPβ send queued data and tear down association. π₯ - Domain
PF_INET, TypeSOCK_STREAM, ProtocolIPPROTO_TCPβ send queued data, wait for ACK, then send FIN. π₯ - Domain
PF_INET6, TypeSOCK_DGRAM, ProtocolIPPROTO_SCTPβ failure, as socket is not connected. π - Domain
PF_INET6, TypeSOCK_DGRAM, ProtocolIPPROTO_UDPβ failure, as socket is not connected. π - Domain
PF_INET6, TypeSOCK_STREAM, ProtocolIPPROTO_SCTPβ send queued data and tear down association. π₯ - Domain
PF_INET6, TypeSOCK_STREAM, ProtocolIPPROTO_TCPβ send queued data, wait for ACK, then send FIN. π₯
π RETURN VALUES π
The shutdown() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.
so: 0 = slay, -1 = the group chat has bad news and errno is the receipts π±
π ERRORS π
The shutdown() system call fails if:
EBADFβ thesargument is not a valid file descriptor. π©EINVALβ thehowargument is invalid. π©ENOTCONNβ thesargument specifies a socket which is not connected. π©ENOTSOCKβ thesargument does not refer to a socket. π©
bestie not every one of these is your fault but every one of these means you're not getting what you wanted π
π SEE ALSO π
connect(2), socket(2), inet(4), inet6(4)
β STANDARDS β
The shutdown() system call is expected to comply with IEEE Std 1003.1g-2000 (βPOSIX.1β), when finalized. pending finalization, we wait π«Ά
π HISTORY π
The shutdown() system call appeared in 4.2BSD. The SHUT_RD, SHUT_WR, and SHUT_RDWR constants appeared in IEEE Std 1003.1g-2000 (βPOSIX.1β). a legacy icon fr fr π
π AUTHORS π
This manual page was updated by Bruce M. Simpson <bms@FreeBSD.org> to reflect how shutdown() behaves with PF_INET and PF_INET6 sockets. thank you for your service π«‘π
π BUGS π
The ICMP βport unreachableβ message should be generated in response to datagrams received on a local port to which s is bound after shutdown() is called.
ngl that one's just... not happening when it should π noted, not fixed.
and that's the whole page bestie π this one's from the Debian crew, dated July 27, 2015 β go forth and close your sockets responsibly β¨
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2007 Bruce M. Simpson
- Copyright (c) 1983, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms