LDAP_OPT_CONNECT_TIMEOUT

Use the LDAP_OPT_CONNECT_TIMEOUT setting to specify a timeout value in seconds and microseconds for LDAP C clients.

Default behavior is blocking. If LDAP_OPT_CONNECT_TIMEOUT is set then it is unblocking.

Client library receives timeout value as Struct timeval pointer. For example, specify a 10-second timeout value as follows:
struct timeval tv = { 10 , 0 };
ldap_set_option( ld, LDAP_OPT_CONNECT_TIMEOUT, &tv );