Lianja
Lianja
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 Lianja Downloads
llSuccess = .F.
loSocket = createobject("CkSocket")
// Connect to the server using TLS.
llBTls = .T.
lnMaxWaitMs = 5000
llSuccess = loSocket.Connect("example.com",5000,llBTls,lnMaxWaitMs)
if (llSuccess = .F.) then
? loSocket.LastErrorText
release loSocket
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.
loDupSock = createobject("CkSocket")
llSuccess = loSocket.DupSocket(loDupSock)
if (llSuccess = .F.) then
? loSocket.LastErrorText
release loSocket
release loDupSock
return
endif
? "Duplicate socket wrapper created."
release loSocket
release loDupSock