- MongoDB C Driver 1.13.1 »
- API Reference »
- mongoc_topology_description_t

# mongoc_topology_description_has_readable_server()

## Synopsis

    bool
    mongoc_topology_description_has_readable_server (
       mongoc_topology_description_t *td, const mongoc_read_prefs_t *prefs);

Determines if the topology has a readable server available. Servers are filtered by the given read preferences only if the driver is connected to a replica set, otherwise the read preferences are ignored. This function uses the driver’s current knowledge of the state of the MongoDB server or servers it is connected to; it does no I/O and it does not block.

Use this function in a topology-changed callback registered with mongoc_apm_set_topology_changed_cb(). For historical reasons, the mongoc_topology_description_t passed to the callback is a const pointer, you must cast away const to pass the pointer to `mongoc_topology_description_has_readable_server`.

## Parameters

- `td`: A mongoc_topology_description_t.
- `read_prefs`: A mongoc_read_prefs_t or `NULL` for default read preferences.

## Returns

True if there is a known server matching `prefs`.

## See Also

Introduction to Application Performance Monitoring

Created using Sphinx 1.8.3, based on Sphinx Readable Theme.