MONGOC_CLIENT...KE_DESCRIPTION(3)
π MONGOC_CLIENT...KE_DESCRIPTION(3) β¨
okay so this is a page straight out of libmongoc, bestie β the C driver manual, no cap. sit down, grab a strawberry drink π, and let's get into it.
β¨ 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);
so this one hands you back a description that's built from the initial handshake response to a server. that's the whole vibe of it π«Ά
πΈ DESCRIPTION πΈ
mongoc_client_get_handshake_description() is not the same thing as mongoc_client_get_server_description(), and the way people mix them up is giving "read the docs" energy π. mongoc_client_get_server_description() gives you a server description built from monitoring, and that one may genuinely differ from the server description you get from the connection handshake. different sources, different tea β
mongoc_client_get_handshake_description() will try to establish a connection to the server if one wasn't already established. and yes, it does the MongoDB handshake and authentication too if those are required. it's doing the full routine, not just showing up π
bestie, listen: use this function only when you're building a language driver that wraps the C Driver. if you're writing applications in C, the higher-level functions automatically select a suitable server for you β let them cook π
π¦ Single-threaded client behavior π¦
single-threaded clients only have one active connection to each server. that one connection is used for both monitoring and application operations β sharing is caring, i guess π
but even so, the server description returned by mongoc_client_get_handshake_description() may still differ from the one returned by mongoc_client_get_server_description(). literally still different. and the notable case is when you're connected to a load balanced cluster:
- the server description from
mongoc_client_get_server_description()describes the load balancer server βmongoc_server_description_type()will return"LoadBalancer" - the server description from
mongoc_client_get_handshake_description()describes the backing server
so likeβ¦ same cluster, different main characters π
π PARAMETERS π
clientβ amongoc_client_t. your client, your girlie, your whole world.server_idβ the ID of the server. you can get this from the server description ofmongoc_client_select_server(). it's giving "go ask the source" β¨optsβ unused. passNULL. that's it. that's the whole assignment π«Άerrorβ an optional location for abson_error_t, orNULLif you're feeling brave (or just don't want the error report).
π₯ RETURNS π₯
a mongoc_server_description_t β and you must free it with mongoc_server_description_destroy(). do not leave it hanging, that's not the vibe π
if a connection has not been successfully established to a server, it returns NULL and error gets filled out. so check your error, bestie, fr fr π
π SEE ALSO π
mongoc_client_select_server()β to select a server from read preferences, iykykmongoc_client_get_server_description()β to obtain the server description from monitoring for a servermongoc_server_description_type()β to obtain the type of server from a server description
π AUTHOR π
MongoDB, Inc β the icons themselves.
β COPYRIGHT β
2009-present, MongoDB, Inc.
and that's the whole page, bestie π§π sign-off time: this was libmongoc, version 2.5.6, dated Oct 09, 2026 β slay, ate, periodt πβ¨
π¦ where this page comes from
- epel 10: mongo-c-driver-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms