[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Connection timeout

On Wed, 18 Jul 2007, Dave Horsfall wrote:
I know about the time limit on the search, but is there a user-specified
one on the connect?

The LDAP_OPT_NETWORK_TIMEOUT option sets a timeout on the connect() call itself. Its value is a struct timeval, so:

        struct timeval          tv;
	int			err;

	tv.tv_sec = timeout_in_seconds;
	tv.tv_usec = 0;

	err = ldap_set_option(ld, LDAP_OPT_NETWORK_TIMEOUT, &tv);
	if (err != LDAP_SUCCESS)

Note that the OS's normal timeout for connection attempts acts as the upper limit on the timeout: requesting a longer timeout will have no effect.

The above option *ONLY* affects the connection attempt and nothing after that.

Philip Guenther