Classic ASP
Classic ASP
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 Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
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.
set imap = Server.CreateObject("Chilkat.Imap")
imap.Ssl = 1
imap.Port = 993
success = imap.Connect("imap.example.com")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( imap.LastErrorText) & "</pre>"
Response.End
End If
' Perform a low-level check of the socket connection state.
stillConnected = imap.CheckConnection()
If (stillConnected = 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "The socket is still connected.") & "</pre>"
Else
Response.Write "<pre>" & Server.HTMLEncode( "The socket is no longer connected.") & "</pre>"
End If
success = imap.Disconnect()
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( imap.LastErrorText) & "</pre>"
Response.End
End If
%>
</body>
</html>