PHP ActiveX
PHP ActiveX
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 PHP ActiveX Downloads
<?php
$success = 0;
$socket = new COM("Chilkat.Socket");
// Connect to the server using TLS.
$bTls = 1;
$maxWaitMs = 5000;
$success = $socket->Connect('example.com',5000,$bTls,$maxWaitMs);
if ($success == 0) {
print $socket->LastErrorText . "\n";
exit;
}
// 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) {
print 'No data is immediately available.' . "\n";
}
else {
print 'Data is available to read.' . "\n";
}
?>