PowerBuilder
PowerBuilder
Check Whether a Socket Is Writable
See more Socket/SSL/TLS Examples
Demonstrates Socket.CheckWriteable, which waits for the connected socket to become writable. It returns 1 if writable, 0 if it did not become writable before the timeout, or -1 on error.
Background. A maxWaitMs of 0 performs a nonblocking poll. This is useful for flow control before attempting a large send.
Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Socket
integer li_BTls
integer li_MaxWaitMs
integer li_Writable
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
// Wait up to 5 seconds for the socket to become writable. Returns 1 if writable, 0 if it did not
// become writable before the timeout, or -1 on error.
li_Writable = loo_Socket.CheckWriteable(5000)
if li_Writable < 0 then
Write-Debug loo_Socket.LastErrorText
destroy loo_Socket
return
end if
if li_Writable <> 1 then
Write-Debug "The socket did not become writable before the timeout."
destroy loo_Socket
return
end if
Write-Debug "The socket is writable."
destroy loo_Socket