public function is_connected()
{
if (!is_resource($this->get_resource())) {
return false;
}
// peek into the connection reading 1 byte ... this works only
// when there is data to read on the connection
if (false === $this->_read_buffer(1, MSG_DONTWAIT ^ MSG_PEEK)) {
return false;
}
// try and read data waiting on the connection into the buffer.
$this->_read_buffer();
$error = socket_get_option($this->get_resource(), SOL_SOCKET, SO_ERROR);
if ($error !== 0) {
$this->error = socket_last_error($this->get_resource());
$this->error_str = socket_strerror($this->error);
return false;
}
return true;
}