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 β€” the socket argument is not a valid file descriptor. not a real fd, sorry 🚫
  • EINVAL β€” the how argument 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 β€” the socket argument 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 πŸ“š


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 πŸŽ€βœ¨