Sample code for 30+ languages & platforms
Xojo Plugin

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 Xojo Plugin Downloads

Xojo Plugin
Dim success As Boolean
success = False

Dim socket As New Chilkat.Socket

//  Connect to the server using TLS.
Dim bTls As Boolean
bTls = True
Dim maxWaitMs As Int32
maxWaitMs = 5000
success = socket.Connect("example.com",5000,bTls,maxWaitMs)
If (success = False) Then
    System.DebugLog(socket.LastErrorText)
    Return
End If

//  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.
Dim dupSock As New Chilkat.Socket
success = socket.DupSocket(dupSock)
If (success = False) Then
    System.DebugLog(socket.LastErrorText)
    Return
End If

System.DebugLog("Duplicate socket wrapper created.")