Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

CURL.SetOptionConnectionTimeout

Sets the connection timeout in seconds.

Component Version macOS Windows Linux Server iOS SDK
CURL 2.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "CURL.SetOptionConnectionTimeout"; curl; Value )   More

Parameters

Parameter Description Example
curl The CURL session handle. $curl
Value The connection timeout time in seconds. 300

Result

Returns "OK" on success.

Description

Sets the connection timeout in seconds.
Pass the maximum time in seconds that you allow the connection to the server to take. This only limits the connection phase, once it has connected, this option is of no more use. Set to zero to switch to the default built-in connection timeout - 300 seconds. See also the CURL.SetOptionTimeOut option.

See also CONNECTTIMEOUT option in CURL manual.

Examples

Set timeout to 30 seconds:

MBS( "CURL.SetOptionConnectionTimeout"; $curl; 30 )

Check if SMB (port 445) is open on a given IP in network:

Let ( [
curl = MBS("CURL.New");
a = MBS( "CURL.SetOptionConnectOnly"; curl; 1 );
b = MBS( "CURL.SetOptionURL"; curl; "192.168.2.117" );
c = MBS( "CURL.SetOptionConnectionTimeout"; curl; 1 );
d = MBS( "CURL.SetOptionPort"; curl; 445 );
r = MBS( "CURL.Perform"; curl );
x = MBS( "CURL.Release"; curl)
]; r )
// returns either
// OK
// or
// 28: Connection timed out after 1000 milliseconds

Try whether google is available:

Let ( [
# new session
curl = MBS("CURL.New");
# only connect, don't transfer data
r = MBS("CURL.SetOptionConnectOnly"; curl; 1);
# limit time to 1 second to connect and 2 seconds in total
r = MBS("CURL.SetOptionConnectionTimeout"; curl; 1);
r = MBS("CURL.SetOptionTimeOut"; curl; 2);
# new connection please
r = MBS("CURL.SetOptionFreshConnect"; curl; 1);
r = MBS("CURL.SetOptionForbidReuse"; curl; 1);
# we query google here
r = MBS("CURL.SetOptionURL"; curl; "http://www.google.de");
# and try it!
result = MBS("CURL.Perform"; curl);
# optionally have log messages go there
// $$log = MBS("CURL.GetDebugMessages"; curl);
# and cleanup
r = MBS("CURL.Release"; curl)
]; result )

See also

Release notes

  • Version 13.2
    • Changed default for CURL.SetOptionConnectionTimeout to 10 seconds (unless you change it) to avoid long stalls in your application of 2 minutes when server is not reachable.

Example Databases

Blog Entries

Created 18th August 2014, last changed 3th January 2023


CURL.SetOptionConnectTo - CURL.SetOptionCookie