Unverified Commit 4597a004 authored by Nathan Van Overloop's avatar Nathan Van Overloop
Browse files

centralnic/issues#3769: try adding global debug

parent 93f6d810
......@@ -39,6 +39,21 @@
*/
var $socket;
/**
* @var bool do output more debug messages
*/
var $debug;
/**
* constructor set initialize various objects
* @param boolean set debugging on
*/
public function __construct($debug = false) {
$this->debug = $debug;
$_GLOBAL['debug']=$debug;
$this->socket = NULL;
}
/**
* Establishes a connect to the server
* This method establishes the connection to the server. If the connection was
......@@ -55,7 +70,7 @@
* @return a string containing the server <greeting>
*/
function connect($host, $port=700, $timeout=1, $ssl=true, $context=NULL) {
debug_log("start connecting");
if($this->debug) debug_log("start connecting");
$target = sprintf('%s://%s:%d', ($ssl === true ? 'tls' : 'tcp'), $host, $port);
if (is_resource($context)) {
......@@ -71,7 +86,7 @@
// Set our socket
$this->socket = $result;
debug_log("connected");
if($this->debug) debug_log("connected");
// Set stream timeout
if (!stream_set_timeout($this->socket,$timeout)) {
......@@ -81,7 +96,7 @@
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");
if($this->debug) debug_log("trying to get frame from server");
return $this->getFrame();
}
......
......@@ -113,6 +113,8 @@ class Net_EPP_Protocol {
* @return string the frame
*/
static function getFrame($socket) {
if($_GLOBAL['debug']) debug_log("start reading first 4 bytes");
// Read header
$hdr = Net_EPP_Protocol::_fread_nb($socket,4);
......
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