55 $context = stream_context_create($this->contextOptions);
57 $flags = STREAM_CLIENT_CONNECT;
60 $flags |= STREAM_CLIENT_ASYNC_CONNECT;
66 $res = stream_socket_client($this->address, $errno, $errstr, $this->socketTimeout, $flags, $context);
70 $res = stream_socket_client($this->address, $errno, $errstr, $this->socketTimeout, $flags);
73 if (is_resource($res))
75 $this->resource = $res;
77 if ($this->streamTimeout > 0)
79 stream_set_timeout($this->resource, $this->streamTimeout);
80 $this->lastTime = time();
87 throw new \RuntimeException($errno > 0 ?
"[{$errno}] {$errstr}" :
'Socket connection error.');