![]()  | 
  
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) Bind and Listen on a Randomly Selected Unused PortDemonstrates how to bind and listen on a randomly selected unused port. Note:The ListenPort property used in this example is available starting in Chilkat v9.5.0.59. 
 integer li_rc oleobject loo_ListenSocket integer li_Success integer li_ListenPort // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_ListenSocket = create oleobject // Use "Chilkat_9_5_0.Socket" for versions of Chilkat < 10.0.0 li_rc = loo_ListenSocket.ConnectToNewObject("Chilkat.Socket") if li_rc < 0 then destroy loo_ListenSocket MessageBox("Error","Connecting to COM object failed") return end if // Pass a value of 0 for the port number to randomly select // an unused port. // (The 2nd argument allows for a backlog of 25 pending connection requests when accepting connections.) li_Success = loo_ListenSocket.BindAndListen(5555,25) if li_Success <> 1 then Write-Debug loo_ListenSocket.LastErrorText destroy loo_ListenSocket return end if // Find out what port was chosen. // Note: The ListenPort propety was added in Chilkat v9.5.0.59 li_ListenPort = loo_ListenSocket.ListenPort Write-Debug "Chosen listen port = " + string(li_ListenPort) destroy loo_ListenSocket  | 
  ||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.