![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Example: Socket.DupSocket methodSee more Socket/SSL/TLS ExamplesDemonstrates how to call the DupSocket method.Note: This example requires Chilkat v11.0.0 or greater.
integer li_rc oleobject loo_Socket integer li_Success oleobject loo_Socket_for_sending oleobject loo_Socket_for_monitor loo_Socket = create oleobject li_rc = loo_Socket.ConnectToNewObject("Chilkat.Socket") if li_rc < 0 then destroy loo_Socket MessageBox("Error","Connecting to COM object failed") return end if li_Success = loo_Socket.Connect("example.com",443,1,5000) // ... // ... // Duplicate the socket to share the same connection across threads. // In a multithreaded application, each thread should use its own socket object. For example: // - The main thread can use the original socket for reading. // - A secondary thread can use a duplicate for writing. // - Another thread can use a separate duplicate to monitor the connection status. loo_Socket_for_sending = create oleobject li_rc = loo_Socket_for_sending.ConnectToNewObject("Chilkat.Socket") li_Success = loo_Socket.DupSocket(loo_Socket_for_sending) if li_Success = 0 then Write-Debug loo_Socket.LastErrorText destroy loo_Socket destroy loo_Socket_for_sending return end if loo_Socket_for_monitor = create oleobject li_rc = loo_Socket_for_monitor.ConnectToNewObject("Chilkat.Socket") li_Success = loo_Socket.DupSocket(loo_Socket_for_monitor) if li_Success = 0 then Write-Debug loo_Socket.LastErrorText destroy loo_Socket destroy loo_Socket_for_sending destroy loo_Socket_for_monitor return end if // All three socket objects: socket, socket_for_sending, and socket_for_monitor share the same underlying connection. destroy loo_Socket destroy loo_Socket_for_sending destroy loo_Socket_for_monitor |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.