---
name: "mongoc_uri_new_for_host_port"
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_uri_new_for_host_port"
---

# mongoc\_uri\_new\_for\_host\_port(3)

## SYNOPSIS

```
mongoc_uri_t *
mongoc_uri_new_for_host_port (const char *hostname, uint16_t port);
```

## PARAMETERS

- •

  **hostname**: A string containing the hostname.

- •

  **port**: A uint16\_t.

## DESCRIPTION

Creates a new *mongoc\_uri\_t* based on the hostname and port provided.

## RETURNS

Returns a newly allocated *mongoc\_uri\_t* that should be freed with *mongoc\_uri\_destroy()* when no longer in use.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
