SHUTDOWN(3POSIX)
β¨ SHUTDOWN(3POSIX) β¨
okay so bestie, welcome to the POSIX Programmer's Manual π this one's shutdown, from the 3POSIX corner of the man-page universe, and it's genuinely so useful once it clicks. pull up a chair π
πΈ PROLOG πΈ
This manual page is part of the POSIX Programmer's Manual. Heads up though β the Linux implementation of this interface may differ (so like, go check the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface may not even be implemented on Linux at all. no cap π
π NAME π
shutdown β shut down socket send and receive operations. it's giving "we're done here" energy π
π¦ SYNOPSIS π¦
#include <sys/socket.h>
int shutdown(int socket, int how);
π DESCRIPTION π
okay so the shutdown() function shall cause all or part of a full-duplex connection on the socket associated with the file descriptor socket to be shut down. like, you're closing the convo β maybe just one direction, maybe both π
The shutdown() function takes the following arguments:
socketβ specifies the file descriptor of the socket. that's your lil handle for the connection, bestie π«Άhowβ specifies the type of shutdown. the values are as follows:SHUT_RDβ disables further receive operations. so you're done listening, periodt πSHUT_WRβ disables further send operations. you've said your piece, no more sending π¬SHUT_RDWRβ disables further send and receive operations. both directions, full main character exit π
The shutdown() function disables subsequent send and/or receive operations on a socket, depending on the value of the how argument. that's the whole vibe check right there β¨
π₯ RETURN VALUE π₯
Upon successful completion, shutdown() shall return 0; otherwise, -1 shall be returned and errno set to indicate the error. so 0 is the slay, -1 is the "something went wrong bestie" π
π ERRORS π
The shutdown() function shall fail if:
EBADFβ thesocketargument is not a valid file descriptor. not a real fd, sorry π«EINVALβ thehowargument is invalid. that's not one of the three values, babe πENOTCONNβ the socket is not connected. there's literally nobody on the other end πENOTSOCKβ thesocketargument does not refer to a socket. that's not a socket at all, it's giving impostor π
The shutdown() function may fail if:
ENOBUFSβ insufficient resources were available in the system to perform the operation. the system is lowkey broke rn π
The following sections are informative. (yes, that means everything below is bonus content, not the actual spec π)
π EXAMPLES π
None. yeah, nothing here. iconic of them honestly π
π APPLICATION USAGE π
None. also nothing. we love a low-effort section β¨
π§ RATIONALE π§
None. same energy, bestie πΈ
β FUTURE DIRECTIONS β
None. the future is unspecified and honestly, same π
π SEE ALSO π
getsockopt(), pselect(), read(), recv(), recvfrom(), recvmsg(), send(), sendto(), setsockopt(), socket(), write()
The Base Definitions volume of POSIX.1β2017, <sys_socket.h>
go read those too, iykyk π
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
IEEE/The Open Group, 2017 β that's the source, the version and the date all rolled into one, and that's a wrap bestie π«Άπ shutdown() understood, no cap, you ate πβ¨
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms