The value used as specified by the connectTimeoutMS option you specify will actually be less.
In mongoc-client.c::mongoc_client_connect_tcp() we have
104 expire_at = bson_get_monotonic_time () + (connecttimeoutms * 1000L);
That value is then eventually passed down to mongoc-socket.c::_mongoc_socket_wait() where we have
133 timeout = (int)((expire_at - bson_get_monotonic_time ()) / 1000L);
Obviously at this point some amount of time will have already passed, so the time out will be less than what was specified. I'm seeing some quite large variations, with a connectTimeoutMS=100 I have seen the actual time out as low as 2.
Also, seeing as the time out argument to poll(2) is simply a duration in milliseconds, as quoted from the man page
"The timeout argument specifies the minimum number of milliseconds that
poll() will block."
Is there any reason to not just pass the connectTimeoutMS value as is?
Cheers,
Andrew