PowerBuilder
PowerBuilder
Poll a Socket for Available Data
See more Socket/SSL/TLS Examples
Demonstrates Socket.PollDataAvailable, which performs a nonblocking check for readable activity and returns whether data or another read-ready condition is present.
Background. This lets an application check for incoming data without blocking, for example in an event loop that services multiple tasks.
Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Socket
integer li_BTls
integer li_MaxWaitMs
integer li_BAvailable
li_Success = 0
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
// Connect to the server using TLS.
li_BTls = 1
li_MaxWaitMs = 5000
li_Success = loo_Socket.Connect("example.com",5000,li_BTls,li_MaxWaitMs)
if li_Success = 0 then
Write-Debug loo_Socket.LastErrorText
destroy loo_Socket
return
end if
// Perform a nonblocking check for readable data. Returns 1 when data or another read-ready
// condition is present, and 0 when nothing is immediately available.
li_BAvailable = loo_Socket.PollDataAvailable()
if li_BAvailable <> 1 then
Write-Debug "No data is immediately available."
else
Write-Debug "Data is available to read."
end if
destroy loo_Socket