Warning: socket_read() [function.socket-read]
Posted: Thu Jul 13, 2006 12:09 pm
can anyone shine some light on this?
I have this code to check if an aim user is on line.
approx. 1/10 executions I recieve this error.
anyone know what may cause this?
I have this code to check if an aim user is on line.
Code: Select all
<?php
function aimStatus($sn) {
$port = "80";
$address = "big.oscar.aol.com";
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if($socket < 0) echo "error: " . socket_strerror($socket) . "\n";
$result = socket_connect($socket, $address, $port);
if($result < 0) echo "error: " . socket_strerror($result) . "\n";
$in = "GET /" . $sn . "?on_url=true&off_url=false HTTP/1.0\r\n";
$in .= "Connection: Close\r\n\r\n";
$out = '';
socket_write($socket, $in, strlen($in));
while ($out = socket_read($socket, 2048)) {
if (strstr($out, "true")==True) {
return TRUE;
} elseif (strstr($out, "false")==True) {
return FALSE;
} else {
return FALSE;;
}
}
socket_close($socket);
}
$time_start = microtime(true);
if(aimStatus($_GET['sn']) == TRUE) echo "Online";;
if(aimStatus($_GET['sn']) != TRUE) echo "Offline";;
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "<br /><br />Executed in $time seconds\n";
?>Code: Select all
Warning: socket_read() [function.socket-read]: unable to read from socket [0]: An existing connection was forcibly closed by the remote host. in U:\wwwroot\htdocs\forbidden\aimstatus.php on line 18