SHUTDOWN(3P)

πŸ’… SHUTDOWN(3P) β€” the POSIX Programmer's Manual era πŸ’…

okay bestie, quick vibe check before we dive in: this page is part of the POSIX Programmer's Manual, and the Linux implementation of this interface may differ β€” so if you're on Linux, go peek at the corresponding Linux manual page for the deets on Linux behavior. orrr the interface might not even be implemented on Linux at all. πŸ™ˆ no cap, always double-check.


✨ NAME ✨

shutdown β€” shut down socket send and receive operations πŸ›‘


πŸŽ€ SYNOPSIS πŸŽ€

#include <sys/socket.h>

int shutdown(int socket, int how);

🌸 DESCRIPTION 🌸

so like. 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. it's giving "we're closing the group chat, but maybe just one direction of it." πŸ’€

shutdown() takes these arguments, bestie:

  • socket β€” specifies the file descriptor of the socket. it's literally the socket's little name tag. 🏷️
  • how β€” specifies the type of shutdown. the values are as follows:
    • SHUT_RD β€” disables further receive operations. πŸ™…β™€οΈπŸ“₯
    • SHUT_WR β€” disables further send operations. πŸ™…β™€οΈπŸ“€
    • SHUT_RDWR β€” disables further send and receive operations. both directions, gone, iconic. ✌️

so yeah β€” shutdown() disables subsequent send and/or receive operations on a socket, depending on the value of the how argument. the how argument is truly the main character here, deciding which direction of the conversation gets ghosted. πŸ‘‘


⭐ RETURN VALUE ⭐

upon successful completion, shutdown() shall return 0. slay. πŸŽ‰

otherwise, -1 shall be returned and errno set to indicate the error. not slay. 😭


πŸ’€ ERRORS πŸ’€

the shutdown() function shall fail if:

  • EBADF β€” the socket argument is not a valid file descriptor. that's not a real socket, bestie, that's a fake ID. πŸͺͺ
  • EINVAL β€” the how argument is invalid. you gave it a vibe it does not recognize. 🚫
  • ENOTCONN β€” the socket is not connected. it's giving "we were never even talking??" 🫠
  • ENOTSOCK β€” the socket argument does not refer to a socket. wrong item, wrong aisle. πŸ›’

the shutdown() function may fail if:

  • ENOBUFS β€” insufficient resources were available in the system to perform the operation. the system was simply not built for this today. πŸ’Έ
heads up: the following sections are informative. they're the bonus tracks, not the main album. 🎧

🌈 EXAMPLES 🌈

None. (yes, literally none. we're on our own, bestie. 🧚)


πŸ’œ APPLICATION USAGE πŸ’œ

None. (also none. the manual is being mysterious and honestly? respect. ✨)


πŸ¦‹ RATIONALE πŸ¦‹

None. (nothing here either. it's giving minimalism. πŸŽ€)


πŸ“ FUTURE DIRECTIONS πŸ“

None. (the future is, apparently, undefined. πŸ™ˆ)


πŸ‘‘ SEE ALSO πŸ‘‘

go read these too, they're all in the same friend group:

getsockopt(), pselect(), read(), recv(), recvfrom(), recvmsg(), send(), sendto(), setsockopt(), socket(), write()

and from the Base Definitions volume of POSIX.1‐2017: <sys_socket.h> πŸ“š


okay this part is serious, so listen up. 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 . πŸ›


and that's the whole page, bestie!! courtesy of IEEE/The Open Group, dated 2017 β€” SHUTDOWN(3P) and out. go forth and close those socket connections with main character energy. periodt. πŸ’…βœ¨πŸ«Ά

πŸ“¦ where this page comes from