Sample code for 30+ languages & platforms
Visual FoxPro

SSL Client Example

See more Socket/SSL/TLS Examples

Demonstrates how to connect to an SSL server, send a simple message, receive a simple response, and disconnect.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loSocket
LOCAL lnSsl
LOCAL lnMaxWaitMillisec
LOCAL lcSslServerHost
LOCAL lnSslServerPort
LOCAL lcReceivedMsg

lnSuccess = 0

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

loSocket = CreateObject('Chilkat.Socket')

lnSsl = 1
lnMaxWaitMillisec = 20000

* The SSL server hostname may be an IP address, a domain name,
* or "localhost".  You'll need to change this:

lcSslServerHost = "123.123.88.88"
lnSslServerPort = 8123

* Connect to the SSL server:
lnSuccess = loSocket.Connect(lcSslServerHost,lnSslServerPort,lnSsl,lnMaxWaitMillisec)
IF (lnSuccess <> 1) THEN
    ? loSocket.LastErrorText
    RELEASE loSocket
    CANCEL
ENDIF

* Set maximum timeouts for reading an writing (in millisec)
loSocket.MaxReadIdleMs = 20000
loSocket.MaxSendIdleMs = 20000

* Send a "Hello Server! -EOM-" message:
lnSuccess = loSocket.SendString("Hello Server! -EOM-")
IF (lnSuccess <> 1) THEN
    ? loSocket.LastErrorText
    RELEASE loSocket
    CANCEL
ENDIF

* The server (in this example) is going to send a "Hello Client! -EOM-" 
* message.  Read it:
lcReceivedMsg = loSocket.ReceiveUntilMatch("-EOM-")
IF (loSocket.LastMethodSuccess <> 1) THEN
    ? loSocket.LastErrorText
    RELEASE loSocket
    CANCEL
ENDIF

* Close the connection with the server
* Wait a max of 20 seconds (20000 millsec)
lnSuccess = loSocket.Close(20000)

? lcReceivedMsg

RELEASE loSocket