Xbase++
Xbase++
Duplicate a Socket Wrapper Sharing the Connection
See more Socket/SSL/TLS Examples
Demonstrates Socket.DupSocket, which populates a destination Socket with another wrapper that shares this object's underlying connection.
Background. The shared connection is reference-counted, and all wrappers operate on the same live connection. The destination first releases any connection it previously held.
Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oSocket
LOCAL nBTls
LOCAL nMaxWaitMs
LOCAL oDupSock
nSuccess := 0
oSocket := CreateObject("Chilkat.Socket")
// Connect to the server using TLS.
nBTls := 1
nMaxWaitMs := 5000
nSuccess := oSocket:Connect("example.com", 5000, nBTls, nMaxWaitMs)
IF (nSuccess == 0)
? oSocket:LastErrorText
oSocket:destroy()
RETURN
ENDIF
// Create a second Socket wrapper that shares this object's underlying connection. Both wrappers
// operate on the same live connection; the shared connection is reference-counted.
oDupSock := CreateObject("Chilkat.Socket")
nSuccess := oSocket:DupSocket(oDupSock)
IF (nSuccess == 0)
? oSocket:LastErrorText
oSocket:destroy()
oDupSock:destroy()
RETURN
ENDIF
? "Duplicate socket wrapper created."
oSocket:destroy()
oDupSock:destroy()