Unverified Commit 93f6d810 authored by Nathan Van Overloop's avatar Nathan Van Overloop
Browse files

centralnic/issues#3769: insert context anyhow and add more debug

parent 1425fb3a
......@@ -57,10 +57,22 @@
function connect($host, $port=700, $timeout=1, $ssl=true, $context=NULL) {
debug_log("start connecting");
$target = sprintf('%s://%s:%d', ($ssl === true ? 'tls' : 'tcp'), $host, $port);
if (!$this->socket = @stream_socket_client($target, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT,$context)) {
throw new Exception("Error connecting to $target: $errstr (code $errno)");
if (is_resource($context)) {
$result = stream_socket_client($target, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context);
} else {
debug_log("connection succeeded");
$result = stream_socket_client($target, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT);
if ($result === False) {
throw new Exception("Error connecting to $target: $errstr (code $errno)");
// Set our socket
$this->socket = $result;
// Set stream timeout
if (!stream_set_timeout($this->socket,$timeout)) {
throw new Exception("Failed to set timeout on socket: $errstr (code $errno)");
......@@ -69,12 +81,10 @@
if (!stream_set_blocking($this->socket,0)) {
throw new Exception("Failed to set blocking on socket: $errstr (code $errno)");
debug_log("trying to get frame from server");
return $this->getFrame();
* Get an EPP frame from the server.
* This retrieves a frame from the server. Since the connection is blocking, this
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment