MONGOC_STREAM_READ(3)
πΈ MONGOC_STREAM_READ(3) πΈ
okay so bestie, this one's from libmongoc and it's genuinely one of the more lowkey-important little functions in the whole stream saga. it's giving "tiny signature, big feelings." let's get into it π
β¨ SYNOPSIS β¨
ssize_t
mongoc_stream_read (mongoc_stream_t *stream,
void *buf,
size_t count,
size_t min_bytes,
int32_t timeout_msec);
look at her. five arguments. no notes. π
π PARAMETERS π
streamβ amongoc_stream_t. the stream you're reading from, obviously. she's the main character here.bufβ the buffer to read into. like, the bucket you're dumping the bytes into πͺ£countβ the number of bytes to read. how much you want, ideally.min_bytesβ the minimum number of bytes to read, or else indicate failure. this is the "i'll accept less thancount, but if you give me less than this i'm calling it a fail" number.timeout_msecβ the number of milliseconds to wait before failure. a timeout of0will not block (fr fr, zero blocking). if it's negative, use the default timeout.
the mongoc_stream_read() function shall perform a read from a mongoc_stream_t. it's modeled on the API and semantics of read(), though the parameters map only loosely β like, they're cousins, not twins. iykyk π
β οΈ WARNING: the "default timeout" indicated by a negative value is both unspecified and unrelated to the documented default values for*TimeoutMSURI options. so do not go assuming they're the same thing, bestie, they are not. to specify a default timeout value for a*TimeoutMSURI option, use theMONGOC_DEFAULT_*constants defined inmongoc-client.h. that's the icon right there π
π¦ RETURNS π¦
the mongoc_stream_read() function returns the number of bytes read on success. slay π«
it returns >= 0 and < min_bytes when end-of-file is encountered β yes, that's a subtle little in-between zone, clock it β and -1 on failure. and when it fails, errno is set upon failure. so check your errno, she's talking to you π
π SEE ALSO π
mongoc_stream_readv()mongoc_stream_write()mongoc_stream_writev()
the whole friend group. readv and writev are the vectorized girlies, write is the classic. go say hi π«Ά
π AUTHOR π
MongoDB, Inc
β COPYRIGHT β
2009-present, MongoDB, Inc.
and that's the whole page, no cap. shoutout to libmongoc 2.5.6, dated Oct 09, 2026 β like, she's documented, she's timestamped, she ate and left no crumbs πβ¨ go read some bytes bestie π
π¦ where this page comes from
- epel 10: mongo-c-driver-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms