}
$write = NULL;
$except = NULL;
- $num_changed_sockets = stream_select($read, $write, $except, 5, 0);
+ $num_changed_sockets = stream_select($read, $write, $except, 0, 500000);
if ($num_changed_sockets == 0) {
printf(" no data in 5 secs ");
}
if ($sock === $this->list) {
printf("NUOVA CONNEX\n");
- $new_unix = stream_socket_accept($this->list);
+ if (($new_unix = stream_socket_accept($this->list)) == FALSE) {
+ printf("SOCKET_ACCEPT FAILED\n");
+ continue;
+ }
$stream_info = "";
$method = "";
$get = array();
}
}
else {
- if (($buf = fread($sock, 512)) === FALSE) {
- printf("error read\n");
- }
- else if (strlen($buf) === 0) {
+ $buf = fread($sock, 512);
+ if ($buf == FALSE || strlen($buf) == 0) {
+ if ($buf == FALSE) {
+ printf("ERROR READING\n");
+ }
if ($sock === $this->list) {
printf("Arrivati %d bytes da list\n", strlen($buf));
+ exit(21);
}
else if ($sock === $this->in) {
printf("Arrivati %d bytes da stdin\n", strlen($buf));
+ exit(22);
}
else {
// $user_a[$s2u[intval($sock)]]->disable();
}
unset($this->socks[intval($sock)]);
unset($this->s2u[intval($sock)]);
- fclose($sock);
- printf("CLOSE ON READ\n");
}
+ fclose($sock);
+ printf("CLOSE ON READ\n");
+
if ($this->debug > 1) {
printf("post unset\n");
print_r($this->socks);
if ($response != "") {
// echo "SPIA: [".substr($response, 0, 60)."...]\n";
- echo "SPIA: [".$response."...]\n";
+ echo "SPIA: [".$response."]\n";
$response_l = mb_strlen($response, "ASCII");
$wret = @fwrite($sock, $response);
if ($wret < $response_l) {
} // function run(...
}
-?>
\ No newline at end of file
+?>