---
name: "bson_reader_new_from_fd"
section: "3"
platform: "linux"
package: "libbson-doc"
version: "1.30.4-1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/bson_reader_new_from_fd"
---

# bson\_reader\_new\_from\_fd(3)

## SYNOPSIS

```
bson_reader_t *
bson_reader_new_from_fd (int fd, bool close_on_destroy);
```

## PARAMETERS

- •

  **fd**: A valid file-descriptor.

- •

  **close\_on\_destroy**: Whether **close()** should be called on **fd** when the reader is destroyed.

## DESCRIPTION

The *bson\_reader\_new\_from\_fd()* function shall create a new *bson\_reader\_t* that will read from the provided file-descriptor.

fd *MUST* be in blocking mode.

If **close\_fd** is true, then **fd** will be closed when the *bson\_reader\_t* is destroyed with *bson\_reader\_destroy()*.

## RETURNS

A newly allocated *bson\_reader\_t* that should be freed with *bson\_reader\_destroy()*.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
