]> git.mxchange.org Git - hub.git/commitdiff
Added more logging.
authorRoland Haeder <roland@mxchange.org>
Tue, 22 Dec 2015 20:23:09 +0000 (21:23 +0100)
committerRoland Haeder <roland@mxchange.org>
Tue, 22 Dec 2015 20:23:51 +0000 (21:23 +0100)
Signed-off-by: Roland Haeder <roland@mxchange.org>
application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php

index 3db9b16c97afc4ff6d8c9eaba8afd9271dc191f4..ba7e7393ba27c70425a87e4bb17478d49ef48585 100644 (file)
@@ -113,9 +113,6 @@ class BaseIpV4ConnectionHelper extends BaseConnectionHelper {
                assert(isset($unlData[UniversalNodeLocator::UNL_PART_ADDRESS]));
                assert(isset($unlData[UniversalNodeLocator::UNL_PART_PORT]));
 
-               // Get current time
-               $time = time();
-
                // "Cache" socket resource and timeout config
                $socketResource = $this->getSocketResource();
                $timeout = $this->getConfigInstance()->getConfigEntry('socket_timeout_seconds');
@@ -123,6 +120,9 @@ class BaseIpV4ConnectionHelper extends BaseConnectionHelper {
                // Debug output
                self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Trying to connect to ' . $unlData[UniversalNodeLocator::UNL_PART_ADDRESS] . ':' . $unlData[UniversalNodeLocator::UNL_PART_PORT] . ' with socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' ...');
 
+               // Get current time
+               $time = time();
+
                // Try to connect until it is connected
                while ($isConnected = !@socket_connect($socketResource, $unlData[UniversalNodeLocator::UNL_PART_ADDRESS], $unlData[UniversalNodeLocator::UNL_PART_PORT])) {
                        // Get last socket error
@@ -132,6 +132,9 @@ class BaseIpV4ConnectionHelper extends BaseConnectionHelper {
                        if (($socketError == SOCKET_EINPROGRESS) || ($socketError == SOCKET_EALREADY)) {
                                // Now, is that attempt within parameters?
                                if ((time() - $time) >= $timeout) {
+                                       // Debug message
+                                       /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: timeout=' . $timeout .' reached, connection attempt failed.');
+
                                        // Didn't work within timeout
                                        $isConnected = FALSE;
                                        break;
@@ -140,12 +143,18 @@ class BaseIpV4ConnectionHelper extends BaseConnectionHelper {
                                // Sleep about one second
                                $this->idle(1000);
                        } elseif ($socketError != 0) {
+                               // Debug message
+                               /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: socketError=' . $socketError . ' detected.');
+
                                // Stop on everything else pronto
                                $isConnected = FALSE;
                                break;
                        }
                } // END - while
 
+               // Log error code
+               /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: socketError=' . $socketError . ',isConnected=' . intval($isConnected) . ' after while() loop.');
+
                // Is the peer connected?
                if ($isConnected === TRUE) {
                        // Connection is fully established here, so change the state.