Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 9.1   9.2   9.3   9.4   9.5   10.0   10.1   10.2   10.3   10.4    Statistic  


Connect only.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
CURL 7.2 Yes Yes Yes Yes Yes
MBS( "CURL.SetOptionConnectOnly"; curl; Value )   More


Parameter Description Example
curl The CURL session handle. $curl
Value The option value.


Returns OK or error.


Connect only.
A 1 tells the library to perform any required proxy authentication and connection setup, but no data transfer.

Use this option to tell CURL to connect only and then send/receive data with your own protocol.
See CURL.SendData, CURL.SendText, CURL.ReceiveText and CURL.ReceiveData.

See also CONNECT_ONLY option in CURL manual.


Download website and handle protocol ourself:

#Start new session
Set Variable [$curl; Value:MBS("CURL.New")]
#Set URL to load (HTTP, HTTPS, FTP, FTPS, SFTP, etc.)
Set Variable [$result; Value:MBS("CURL.SetOptionConnectOnly"; $curl; 1)]
Set Variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; CURL Low Level Sockets::URL)]
Set Variable [$request; Value:"GET / HTTP/1.1¶Host:¶¶" // must end with two empty lines ]
Set Variable [$request2; Value:MBS( "Text.ReplaceNewline"; $request; 3)]
#RUN now
Set Field [CURL Low Level Sockets::Connect Result; MBS("CURL.Perform"; $curl)]
#Check result
Set Field [CURL Low Level Sockets::Data Received; MBS("CURL.GetResultAsText"; $curl; "UTF8")]
Set Field [CURL Low Level Sockets::Debug Messages; MBS("CURL.GetDebugAsText"; $curl)]
If [CURL Low Level Sockets::Connect Result = "OK"]
    Set Variable [$r; Value:MBS( "CURL.SendText"; $curl; $request2; "UTF-8")]
    Set Field [CURL Low Level Sockets::Data Sent; $request]
    Set Variable [$received; Value:""]
        Pause/Resume Script [Duration (seconds): ,1]
        Set Variable [$r; Value:MBS( "CURL.ReceiveText"; $curl; 100000; "UTF-8")]
        Set Variable [$errorCode; Value:MBS( "CURL.ErrorCode"; $curl)]
        If [GetAsNumber ( $errorCode ) = 81]
        Else If [GetAsNumber ( $errorCode ) = 0]
            #got some data
            Set Variable [$received; Value:$received & $r]
            Exit Loop If [$r = ""]
            Exit Loop If [1]
        End If
    End Loop
    Set Variable [$received2; Value:MBS( "Text.ReplaceNewline"; $received; 1)]
    Set Field [CURL Low Level Sockets::Debug Messages; MBS("CURL.GetDebugAsText"; $curl)]
    Set Field [CURL Low Level Sockets::Data Received; $received2]
End If
Set Variable [$result; Value:MBS("CURL.Release"; $curl)]

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; "" );
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

See also

Example Databases

Blog Entries

Created 27th March 2017, last changed 19th April 2020

CURL.SetOptionCertInfo   -   CURL.SetOptionConnectTimeoutMS

Feedback: Report problem or ask question.

MBS Xojo Plugins