Sample code for 30+ languages & platforms
VB.NET

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 VB.NET Downloads

VB.NET
Dim success As Boolean = False

Dim socket As New Chilkat.Socket

'  Connect to the server using TLS.
Dim bTls As Boolean = True
Dim maxWaitMs As Integer = 5000
success = socket.Connect("example.com",5000,bTls,maxWaitMs)
If (success = False) Then
    Debug.WriteLine(socket.LastErrorText)
    Exit Sub
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
    Debug.WriteLine(socket.LastErrorText)
    Exit Sub
End If

Debug.WriteLine("Duplicate socket wrapper created.")