SYNOPSIS

ssize_t
mongoc_stream_read (mongoc_stream_t *stream,
                    void            *buf,
                    size_t           count,
                    size_t           min_bytes,
                    int32_t          timeout_msec);

DESCRIPTION

The mongoc_stream_read() function shall perform a read from a mongoc_stream(7). It’s modeled on the API and semantics of read(2), though the parameters map only loosely.

buf

A buffer of at least count bytes that is safe to write to.

count

The size of the buffer buf

min_bytes

The minimum number of bytes to attempt to read. This performs whatever iteration is necessary to gather that many bytes from the underlying transport.

timeout_msec

The timeout, in milliseconds, to attempt to read min_bytes. If negative, use the default timeout. A timeout of 0 implies a non-blocking read.

All stream implementations implement read().

RETURN VALUE

The mongoc_stream_read() function returns the number of bytes read on success. It returns >= 0 and < min_bytes when eof is encountered and -1 on failure.

ERRORS

errno may be set by the underlying transport.

There are also mongoc_stream_read() specific errors:

ETIMEDOUT

min_bytes could not be read in timeout_msec.

SEE ALSO

AUTHORS

This page was written by MongoDB Inc.