Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Guides   Examples
New in version: 8.0   8.1   8.2   8.3   8.4   8.5   9.0   9.1   9.2   9.3    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 value
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 than 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.Cleanup"; $curl)]

See also

Example Databases

Created 27th March 2017, last changed 15th April 2018

CURL.SetOptionCertInfo   -   CURL.SetOptionConnectTimeoutMS

Feedback: Report problem or ask question.

MBS Xojo Chart Plugins