Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
Sets the connection timeout in seconds.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
CURL | 2.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example |
---|---|---|
curl | The CURL session handle. | $curl |
Value | The connection timeout time in seconds. | 300 |
Returns "OK" on success.
See also CONNECTTIMEOUT option in CURL manual.
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 )
Created 18th August 2014, last changed 3th January 2023