MONGOC_SOCKET_CLOSE(3)

πŸ’… MONGOC_SOCKET_CLOSE(3) πŸ’…

okay bestie, so this is a page from the libmongoc manual (that's the MongoDB C driver crew, iykyk) and it's literally all about closing a socket. short page, but she's iconic. let's get into it ✨


🌸 SYNOPSIS 🌸

int
mongoc_socket_close (mongoc_socket_t *socket);

that's the whole vibe. returns an int, takes one pointer. slay.


πŸŽ€ PARAMETERS πŸŽ€

  • socket β€” A mongoc_socket_t. that's it. that's the parameter. the main character of this function 🫢

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea: this function is a wrapper around the BSD socket shutdown() and close() functions β€” plus their Windows equivalents, because Windows gotta Windows 😭

here's the important part, no cap: the socket is shut down only if the current process is the same as the process that opened the socket. different process? no shutdown for you. πŸ™ˆ

Regardless, the socket is then closed. so either way, bestie, the close happens. periodt.


⭐ RETURNS ⭐

  • 0 on success πŸ’–
  • -1 on failure to close the socket πŸ’€

on failure, the socket's errno is set β€” grab it with mongoc_socket_errno(). don't forget, or you'll be staring at a -1 wondering what went wrong. not cute.


πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc β€” the legends themselves.


2009-present, MongoDB, Inc.


mwah πŸ’‹ that's the page. version 2.5.6, dated Oct 09, 2026 β€” go close some sockets responsibly, bestie. πŸ“βœ¨

πŸ“¦ where this page comes from