Visual FoxPro
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loSocket
LOCAL lnBTls
LOCAL lnMaxWaitMs
LOCAL loDupSock
lnSuccess = 0
loSocket = CreateObject('Chilkat.Socket')
* Connect to the server using TLS.
lnBTls = 1
lnMaxWaitMs = 5000
lnSuccess = loSocket.Connect("example.com",5000,lnBTls,lnMaxWaitMs)
IF (lnSuccess = 0) THEN
? loSocket.LastErrorText
RELEASE loSocket
CANCEL
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.
loDupSock = CreateObject('Chilkat.Socket')
lnSuccess = loSocket.DupSocket(loDupSock)
IF (lnSuccess = 0) THEN
? loSocket.LastErrorText
RELEASE loSocket
RELEASE loDupSock
CANCEL
ENDIF
? "Duplicate socket wrapper created."
RELEASE loSocket
RELEASE loDupSock