---
name: "mongoc_client_get_handshake_description"
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_client_get_handshake_description"
---

# mongoc\_client\_get\_handshake\_description(3)

## SYNOPSIS

```
mongoc_server_description_t *
mongoc_client_get_handshake_description (mongoc_client_t *client,
                                         uint32_t server_id,
                                         bson_t *opts,
                                         bson_error_t *error);
```

Returns a description constructed from the initial handshake response to a server.

## DESCRIPTION

*mongoc\_client\_get\_handshake\_description()* is distinct from *mongoc\_client\_get\_server\_description()*. *mongoc\_client\_get\_server\_description()* returns a server description constructed from monitoring, which may differ from the server description constructed from the connection handshake.

*mongoc\_client\_get\_handshake\_description()* will attempt to establish a connection to the server if a connection was not already established. It will perform the MongoDB handshake and authentication if required.

Use this function only for building a language driver that wraps the C Driver. When writing applications in C, higher-level functions automatically select a suitable server.

### Single-threaded client behavior

Single-threaded clients only have one active connection to each server. The one connection is used for both monitoring and application operations. However, the server description returned by *mongoc\_client\_get\_handshake\_description()* may still differ from the server description returned by *mongoc\_client\_get\_server\_description()*. Notably, if connected to a load balanced cluster, the server description returned by *mongoc\_client\_get\_server\_description()* will describe the load balancer server (*mongoc\_server\_description\_type()* will return "LoadBalancer"). And the server description returned by *mongoc\_client\_get\_handshake\_description()* will describe the backing server.

## PARAMETERS

- •

  **client**: A *mongoc\_client\_t*.

- •

  **server\_id**: The ID of the server. This can be obtained from the server description of *mongoc\_client\_select\_server()*.

- •

  **opts**: Unused. Pass **NULL**.

- •

  **error**: An optional location for a *bson\_error\_t* or **NULL**.

## RETURNS

A *mongoc\_server\_description\_t* that must be freed with *mongoc\_server\_description\_destroy()*. If a connection has not been successfully established to a server, returns **NULL** and **error** is filled out.

## SEE ALSO

- •

  *mongoc\_client\_select\_server()* To select a server from read preferences.

- •

  *mongoc\_client\_get\_server\_description()* To obtain the server description from monitoring for a server.

- •

  *mongoc\_server\_description\_type()* To obtain the type of server from a server description.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
