From e36fc08eb089e6bae794f9750ec6df3596064503 Mon Sep 17 00:00:00 2001 From: fritzy Date: Mon, 7 Apr 2008 04:06:03 +0000 Subject: [PATCH] * don't hang if connection isn't made git-svn-id: svn://netflint.net/xmpphp@18 ef36c318-a008-4979-b6e8-6b496270793b --- logging.php | 2 +- xmlstream.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/logging.php b/logging.php index dac55f8..861d2cb 100644 --- a/logging.php +++ b/logging.php @@ -38,7 +38,7 @@ class Logging { } function log($msg, $runlevel=Null) { - if(!$runlevel) $runlevel = LOGGING_INFO; + if($runlevel === Null) $runlevel = LOGGING_INFO; $data[] = array($this->runlevel, $msg); if($this->printout and $runlevel <= $this->runlevel) print "{$this->names[$runlevel]}: $msg\n"; } diff --git a/xmlstream.php b/xmlstream.php index 73bbdfc..22b1e27 100644 --- a/xmlstream.php +++ b/xmlstream.php @@ -84,6 +84,10 @@ class XMLStream { } $this->log->log("Connecting to tcp://{$this->host}:{$this->port}"); $this->socket = stream_socket_client("tcp://{$this->host}:{$this->port}", $flags=$conflag); + if(!$this->socket) { + $this->log->log("Could not connect.", LOGGING_ERROR); + $this->disconnected = True; + } stream_set_blocking($this->socket, 1); if($sendinit) $this->send($this->stream_start); }