Answer the question
In order to leave comments, you need to log in
How to find out that the timer has fired on the descriptor created in the stream_socket_client function?
Actually, the data is transferred by the fwrite function, you need to somehow find out if the write on the socket was interrupted by a timer.
function __construct($address, $remote_port, $timeout)
{
$this->address = $address;
$this->port = $remote_port;
$this->timeout = $timeout;
$this->fp = stream_socket_client("tcp://".$address.":".$remote_port, $errno, $errstr, $timeout);
}
public function Send($msg)
{
if (!$this->fp)
{
fclose($this->fp);
return false;
}
else
{
//Здесь нужно как то обработать ошибку таймера
//if (fwrite($this->fp, $msg) == TIMEOUT)
// return TIMEOUT// Что то в этом роде нужно произвести
fwrite($this->fp, $msg);
}
return true;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question