VBScript
VBScript
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 VBScript Downloads
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 0
set socket = CreateObject("Chilkat.Socket")
' Connect to the server using TLS.
bTls = 1
maxWaitMs = 5000
success = socket.Connect("example.com",5000,bTls,maxWaitMs)
If (success = 0) Then
outFile.WriteLine(socket.LastErrorText)
WScript.Quit
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.
set dupSock = CreateObject("Chilkat.Socket")
success = socket.DupSocket(dupSock)
If (success = 0) Then
outFile.WriteLine(socket.LastErrorText)
WScript.Quit
End If
outFile.WriteLine("Duplicate socket wrapper created.")
outFile.Close