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

# mongoc\_socket\_new(3)

## SYNOPSIS

```
mongoc_socket_t *
mongoc_socket_new (int domain,
                   int type,
                   int protocol);
```

## PARAMETERS

- •

  **domain**: An int containing the address family such as AF\_INET.

- •

  **type**: An int containing the socket type such as SOCK\_STREAM.

- •

  **protocol**: A protocol subset, typically 0.

## DESCRIPTION

Creates a new **mongoc\_socket\_t** structure. This calls **socket()** underneath to create a network socket.

## RETURNS

A new socket if successful, otherwise **NULL** and errno is set. The result should be freed with *mongoc\_socket\_destroy()* when no longer in use.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
