Sample code for 30+ languages & platforms
PowerBuilder

Example: Socket.AcceptNext method

Demonstrates how to call the AcceptNext method.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_ListenSocket
oleobject loo_ConnectedSocket
integer li_Port
integer li_Backlog
integer li_MaxWaitMs

li_Success = 0

loo_ListenSocket = create oleobject
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
loo_ConnectedSocket = create oleobject
li_rc = loo_ConnectedSocket.ConnectToNewObject("Chilkat.Socket")

li_Port = 5555
li_Backlog = 25
li_Success = loo_ListenSocket.BindAndListen(li_Port,li_Backlog)
if li_Success = 0 then
    Write-Debug loo_ListenSocket.LastErrorText
    destroy loo_ListenSocket
    destroy loo_ConnectedSocket
    return
end if

// Accept next incoming connection
li_MaxWaitMs = 200000
li_Success = loo_ListenSocket.AcceptNext(li_MaxWaitMs,loo_ConnectedSocket)
if li_Success = 0 then
    Write-Debug loo_ListenSocket.LastErrorText
    destroy loo_ListenSocket
    destroy loo_ConnectedSocket
    return
end if

// ...
// ...

li_MaxWaitMs = 20000
loo_ConnectedSocket.Close()


destroy loo_ListenSocket
destroy loo_ConnectedSocket