MONGOC_SOCKET_RECV(3)

πŸ’… MONGOC_SOCKET_RECV(3) πŸ’…

okay so bestie, this is a page from libmongoc (yes, that libmongoc πŸ’–) and we're about to learn how mongoc_socket_recv scoops bytes out of a socket. it's giving "low-level but make it cute". stay with me 🫢


✨ SYNOPSIS ✨

ssize_t
mongoc_socket_recv (mongoc_socket_t *sock,
                    void *buf,
                    size_t buflen,
                    int flags,
                    int64_t expire_at);

look at that signature. five whole arguments. she's committed πŸ’…


πŸŽ€ PARAMETERS πŸŽ€

  • sock β€” a mongoc_socket_t. like, the actual socket we're reading from. main character energy fr.
  • buf β€” a buffer to read into. this is where the bytes go to live 🏠
  • buflen β€” a size_t with the number of bytes to receive. i.e. how much room you're giving her.
  • flags β€” flags for recv(). the usual suspects, passed straight through, no notes.
  • expire_at β€” a int64_t with the time to expire, in monotonic time using the System Clock, which is in microseconds. yes microseconds. not milliseconds. not seconds. microseconds. iykyk ⏰

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so what does she actually do? literally this: mongoc_socket_recv performs a recv() on the underlying socket. that's it. that's the whole vibe. no extra lore, no secret sauce β€” it's a recv() wrapped in mongoc's little jacket 🌸


🌈 RETURNS 🌈

  • the number of bytes received on success πŸ’–
  • 0 when the stream is closed (she's gone, respect the closure 😭)
  • -1 if there was a failure β€” and heads up, when that happens errno is set, so go check it πŸ‘€

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc. slay.


2009-present, MongoDB, Inc.


friendly reminder bestie: -1 means failure, and errno is set. don't ignore her. she's telling you something πŸ’€

okay that's the page!! written by the legends at MongoDB, Inc, version 2.5.6, dated Oct 09, 2026 β€” mwah, no cap, periodt πŸ’œπŸ§šβ€β™€οΈ

πŸ“¦ where this page comes from