Xbase++
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL oSocket
LOCAL nSsl
LOCAL nMaxWaitMillisec
LOCAL cSslServerHost
LOCAL nSslServerPort
LOCAL cReceivedMsg
nSuccess := 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oSocket := CreateObject("Chilkat.Socket")
nSsl := 1
nMaxWaitMillisec := 20000
// The SSL server hostname may be an IP address, a domain name,
// or "localhost". You'll need to change this:
cSslServerHost := "123.123.88.88"
nSslServerPort := 8123
// Connect to the SSL server:
nSuccess := oSocket:Connect(cSslServerHost, nSslServerPort, nSsl, nMaxWaitMillisec)
IF (nSuccess != 1)
? oSocket:LastErrorText
oSocket:destroy()
RETURN
ENDIF
// Set maximum timeouts for reading an writing (in millisec)
oSocket:MaxReadIdleMs := 20000
oSocket:MaxSendIdleMs := 20000
// Send a "Hello Server! -EOM-" message:
nSuccess := oSocket:SendString("Hello Server! -EOM-")
IF (nSuccess != 1)
? oSocket:LastErrorText
oSocket:destroy()
RETURN
ENDIF
// The server (in this example) is going to send a "Hello Client! -EOM-"
// message. Read it:
cReceivedMsg := oSocket:ReceiveUntilMatch("-EOM-")
IF (oSocket:LastMethodSuccess != 1)
? oSocket:LastErrorText
oSocket:destroy()
RETURN
ENDIF
// Close the connection with the server
// Wait a max of 20 seconds (20000 millsec)
nSuccess := oSocket:Close(20000)
? cReceivedMsg
oSocket:destroy()