Sample code for 30+ languages & platforms
Classic ASP

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 Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

set socket = Server.CreateObject("Chilkat.Socket")

'  Connect to the server using TLS.
bTls = 1
maxWaitMs = 5000
success = socket.Connect("example.com",5000,bTls,maxWaitMs)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( socket.LastErrorText) & "</pre>"
    Response.End
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.
bAvailable = socket.PollDataAvailable()
If (bAvailable <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "No data is immediately available.") & "</pre>"
Else
    Response.Write "<pre>" & Server.HTMLEncode( "Data is available to read.") & "</pre>"
End If


%>
</body>
</html>