PowerBuilder
PowerBuilder
Check the IMAP Socket Connection
See more IMAP Examples
Demonstrates the Chilkat Imap.CheckConnection method, which checks whether the underlying TCP socket is currently connected to the IMAP server. This performs a low-level socket-state check and does not send an IMAP command. This example connects and checks the socket.
Background:
CheckConnection sits between the cached IsConnected and a full protocol round trip: it inspects the actual socket without sending an IMAP command, so it can catch a locally-closed socket that the cached flag would miss. It still cannot detect every half-open connection, though — only a real command like Noop that expects a server reply proves the session is genuinely alive end to end.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Imap
integer li_StillConnected
li_Success = 0
// Demonstrates the Imap.CheckConnection method, which checks whether the underlying TCP
// socket is currently connected to the IMAP server. This is a low-level socket-state check
// and does not send an IMAP command.
loo_Imap = create oleobject
li_rc = loo_Imap.ConnectToNewObject("Chilkat.Imap")
if li_rc < 0 then
destroy loo_Imap
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Imap.Ssl = 1
loo_Imap.Port = 993
li_Success = loo_Imap.Connect("imap.example.com")
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
// Perform a low-level check of the socket connection state.
li_StillConnected = loo_Imap.CheckConnection()
if li_StillConnected = 1 then
Write-Debug "The socket is still connected."
else
Write-Debug "The socket is no longer connected."
end if
li_Success = loo_Imap.Disconnect()
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
destroy loo_Imap