public function connect()
{
if (is_resource($this->stream)) {
return;
}
if (empty($this->host)) {
throw new \Kafka\Exception('Cannot open null host.');
}
if ($this->port <= 0) {
throw new \Kafka\Exception('Cannot open without port.');
}
$this->stream = @fsockopen($this->host, $this->port, $errno, $errstr, $this->sendTimeoutSec + $this->sendTimeoutUsec / 1000000);
if ($this->stream == false) {
$error = 'Could not connect to ' . $this->host . ':' . $this->port . ' (' . $errstr . ' [' . $errno . '])';
throw new \Kafka\Exception\SocketConnect($error);
}
stream_set_blocking($this->stream, 0);
}