From 4cca1e9c61460a8c8eba2677ec66ecb729968db2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 25 Feb 2023 14:14:28 +0100 Subject: [PATCH] Continued: - used lesser debugOutput() and more traceMessage() and its relatives ;-) --- .../socket/class_SocketContainer.php | 220 +++++++++--------- 1 file changed, 110 insertions(+), 110 deletions(-) diff --git a/application/hub/classes/container/socket/class_SocketContainer.php b/application/hub/classes/container/socket/class_SocketContainer.php index 654b4d836..ea728abd1 100644 --- a/application/hub/classes/container/socket/class_SocketContainer.php +++ b/application/hub/classes/container/socket/class_SocketContainer.php @@ -157,7 +157,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public static final function createSocketContainer ($socketResource, string $socketProtocol, DeliverablePackage $packageInstance, string $socketType) { // Validate parameter - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-CONTAINER: socketResource[%s]=%s,socketProtocol=%s,packageInstance=%s,socketType=%s - CALLED!', gettype($socketResource), $socketResource, $socketProtocol, $packageInstance->__toString(), $socketType)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SOCKET-CONTAINER: socketResource[%s]=%s,socketProtocol=%s,packageInstance=%s,socketType=%s - CALLED!', gettype($socketResource), $socketResource, $socketProtocol, $packageInstance->__toString(), $socketType)); if (!is_resource($socketResource)) { // Throw exception throw new InvalidArgumentException(sprintf('socketResource[]=%s is not valid', $socketResource)); @@ -182,7 +182,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita self::$configEntries[sprintf('%s_socket_listen_backlog', $socketInstance->getSocketType())] = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry(sprintf('%s_socket_listen_backlog', $socketInstance->getSocketProtocol())); // Return the prepared instance - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketInstance=%s - EXIT!', strtoupper($socketProtocol), $socketInstance->__toString())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: socketInstance=%s - EXIT!', strtoupper($socketProtocol), $socketInstance->__toString())); return $socketInstance; } @@ -195,7 +195,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function ifAddressMatches (string $unl) { // Is parameter valid? - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unl=%s - CALLED!', strtoupper($this->getSocketProtocol()), $unl)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: unl=%s - CALLED!', strtoupper($this->getSocketProtocol()), $unl)); if (empty($unl)) { // Throw again throw new InvalidArgumentException('Parameter "unl" is empty'); @@ -207,12 +207,12 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita //* DEBUG-DIE: */ if ($this->getSocketType() == StorableSocket::CONNECTION_TYPE_INCOMING) { die(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE))); } // So, does both match? - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketType=%s,packageInstance->recipientUnl=%s', strtoupper($this->getSocketProtocol()), $this->getSocketType(), $packageInstance->getRecipientUnl())); - //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: unl=' . $unl . ',packageInstance=' . print_r($packageInstance, true)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: this->socketType=%s,packageInstance->recipientUnl=%s', strtoupper($this->getSocketProtocol()), $this->getSocketType(), $packageInstance->getRecipientUnl())); + //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(strtoupper($this->getSocketProtocol()) . '-SOCKET: unl=' . $unl . ',packageInstance=' . print_r($packageInstance, true)); $matches = (!empty($packageInstance->getRecipientUnl()) && $packageInstance->getRecipientUnl() === $unl); // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: matches=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($matches))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: matches=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($matches))); return $matches; } @@ -224,11 +224,11 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function ifSocketResourceMatches ($socketResource) { // So, does both match? - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: socketResource[' . gettype($socketResource) . ']=' .$socketResource . ',storedResource[' . gettype($this->getSocketResource()) . ']=' . $this->getSocketResource()); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(strtoupper($this->getSocketProtocol()) . '-SOCKET: socketResource[' . gettype($socketResource) . ']=' .$socketResource . ',storedResource[' . gettype($this->getSocketResource()) . ']=' . $this->getSocketResource()); $matches = ((is_resource($socketResource)) && ($socketResource === $this->getSocketResource())); // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: matches=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($matches))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: matches=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($matches))); return $matches; } @@ -240,19 +240,19 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function shutdownSocket () { // Debug message - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Shutting down socket ' . $this->getSocketResource() . ' with state ' . ($this->getHelperInstance() instanceof Helper ? $this->getHelperInstance()->getPrintableState() : 'NULL') . ' ...'); + self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(strtoupper($this->getSocketProtocol()) . '-SOCKET: Shutting down socket ' . $this->getSocketResource() . ' with state ' . ($this->getHelperInstance() instanceof Helper ? $this->getHelperInstance()->getPrintableState() : 'NULL') . ' ...'); // Get a visitor instance $visitorInstance = ObjectFactory::createObjectByConfiguredName('shutdown_socket_visitor_class'); // Debug output - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET:' . $this->__toString() . ': visitorInstance=' . $visitorInstance->__toString()); + self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(strtoupper($this->getSocketProtocol()) . '-SOCKET:' . $this->__toString() . ': visitorInstance=' . $visitorInstance->__toString()); // Call the visitor $this->accept($visitorInstance); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: EXIT!', strtoupper($this->getSocketProtocol()))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: EXIT!', strtoupper($this->getSocketProtocol()))); } /** @@ -263,19 +263,19 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function halfShutdownSocket () { // Debug message - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Half-shutting down socket resource ' . $this->getSocketResource() . ' with state ' . $this->getHelperInstance()->getPrintableState() . ' ...'); + self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(strtoupper($this->getSocketProtocol()) . '-SOCKET: Half-shutting down socket resource ' . $this->getSocketResource() . ' with state ' . $this->getHelperInstance()->getPrintableState() . ' ...'); // Get a visitor instance $visitorInstance = ObjectFactory::createObjectByConfiguredName('half_shutdown_socket_visitor_class'); // Debug output - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET:' . $this->__toString() . ': visitorInstance=' . $visitorInstance->__toString()); + self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(strtoupper($this->getSocketProtocol()) . '-SOCKET:' . $this->__toString() . ': visitorInstance=' . $visitorInstance->__toString()); // Call the visitor $this->accept($visitorInstance); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: EXIT!', strtoupper($this->getSocketProtocol()))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: EXIT!', strtoupper($this->getSocketProtocol()))); } /** @@ -286,11 +286,11 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function accept (Visitor $visitorInstance) { // Visit this listener - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - CALLED!'); + /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(strtoupper($this->getSocketProtocol()) . '-SOCKET: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - CALLED!'); $visitorInstance->visitSocket($this); // Trace message - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - EXIT!'); + /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(strtoupper($this->getSocketProtocol()) . '-SOCKET: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - EXIT!'); } /** @@ -303,7 +303,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function determineSocketPeerName (string &$peerAddress, int &$peerPort) { // Should be valid socket - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: peerAddress[%s]=%s,peerPort[%s]=%d - CALLED!', strtoupper($this->getSocketProtocol()), gettype($peerAddress), $peerAddress, gettype($peerPort), $peerPort)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: peerAddress[%s]=%s,peerPort[%s]=%d - CALLED!', strtoupper($this->getSocketProtocol()), gettype($peerAddress), $peerAddress, gettype($peerPort), $peerPort)); if (!$this->isValidSocket()) { // Throw exception throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); @@ -326,7 +326,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita } // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: peerAddress=%s,peerPort=%d,result[%s]=%d - EXIT!', strtoupper($this->getSocketProtocol()), $peerAddress, $peerPort, gettype($result), intval($result))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: peerAddress=%s,peerPort=%d,result[%s]=%d - EXIT!', strtoupper($this->getSocketProtocol()), $peerAddress, $peerPort, gettype($result), intval($result))); return $result; } @@ -349,7 +349,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function getSocketRecipientUnl () { // Should be valid socket - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); if (!$this->isValidSocket()) { // Throw exception throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); @@ -359,7 +359,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $packageInstance = $this->getPackageDataInstance(); // Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: packageInstance.recipient=%s - EXIT!', strtoupper($this->getSocketProtocol()), $packageInstance->getRecipientUnl())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: packageInstance.recipient=%s - EXIT!', strtoupper($this->getSocketProtocol()), $packageInstance->getRecipientUnl())); return $packageInstance->getRecipientUnl(); } @@ -371,7 +371,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function getSocketRecipientAddress () { // Should be valid socket - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); if (!$this->isValidSocket()) { // Throw exception throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); @@ -381,14 +381,14 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $recipientUnl = $this->getSocketRecipientUnl(); // Generate UNL instance for it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: recipientUnl=%s', strtoupper($this->getSocketProtocol()), $recipientUnl)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: recipientUnl=%s', strtoupper($this->getSocketProtocol()), $recipientUnl)); $locatorInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($recipientUnl); // Get address part $recipientAddress = $locatorInstance->getUnlAddress(); // Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: recipientAddress=%s - EXIT!', strtoupper($this->getSocketProtocol()), $recipientAddress)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: recipientAddress=%s - EXIT!', strtoupper($this->getSocketProtocol()), $recipientAddress)); return $recipientAddress; } @@ -400,7 +400,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function getSocketRecipientPort () { // Should be valid socket - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); if (!$this->isValidSocket()) { // Throw exception throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); @@ -410,14 +410,14 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $recipientUnl = $this->getSocketRecipientUnl(); // Generate UNL instance for it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: recipientUnl=%s', strtoupper($this->getSocketProtocol()), $recipientUnl)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: recipientUnl=%s', strtoupper($this->getSocketProtocol()), $recipientUnl)); $locatorInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($recipientUnl); // Get port part $recipientPort = $locatorInstance->getUnlPort(); // Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: recipientPort=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($recipientPort))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: recipientPort=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($recipientPort))); return $recipientPort; } @@ -428,12 +428,12 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function isValidSocket () { // Is it valid? - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); // @TODO maybe add more checks? is_resource() is still to less $isValidSocket = (is_resource($this->getSocketResource())); // Return status - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: isValidSocket=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($isValidSocket))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: isValidSocket=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($isValidSocket))); return $isValidSocket; } @@ -445,7 +445,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function getLastSocketErrorCode () { // Should be valid socket - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); if (!$this->isValidSocket()) { // Throw exception throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); @@ -455,7 +455,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $errorCode = socket_last_error($this->getSocketResource()); // Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorCode=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($errorCode))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: errorCode=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($errorCode))); return $errorCode; } @@ -467,7 +467,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function getLastSocketErrorMessage () { // Should be valid socket - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); if (!$this->isValidSocket()) { // Throw exception throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); @@ -477,7 +477,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $errorMessage = socket_strerror($this->getLastSocketErrorCode()); // Return it - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorMessage=%s - EXIT!', strtoupper($this->getSocketProtocol()), $errorMessage)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: errorMessage=%s - EXIT!', strtoupper($this->getSocketProtocol()), $errorMessage)); return $errorMessage; } @@ -488,15 +488,15 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function translateLastSocketErrorCodeToName () { // Get last error code - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); $errorCode = $this->getLastSocketErrorCode(); // Call "translate" method - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorCode=%d', strtoupper($this->getSocketProtocol()), $errorCode)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: errorCode=%d', strtoupper($this->getSocketProtocol()), $errorCode)); $codeName = $this->translateSocketErrorCodeToName($errorCode); // Return it - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: codeName=%s - EXIT!', strtoupper($this->getSocketProtocol()), $codeName)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: codeName=%s - EXIT!', strtoupper($this->getSocketProtocol()), $codeName)); return $codeName; } @@ -509,7 +509,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function bindSocketToFile () { // Should be valid socket - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); if (!$this->isValidSocket()) { // Throw exception throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); @@ -519,11 +519,11 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita } // Try to bind it to - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Binding socket to file %s ...', strtoupper($this->getSocketProtocol()), $this->getSocketFile())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: Binding socket to file %s ...', strtoupper($this->getSocketProtocol()), $this->getSocketFile())); $result = socket_bind($this->getSocketResource(), $this->getSocketFile()); // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); return $result; } @@ -538,7 +538,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function bindSocketToListener () { // Should be valid socket - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); if (!$this->isValidSocket()) { // Throw exception throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); @@ -552,11 +552,11 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $port = $this->getListenerInstance()->getListenPort(); // Try to bind it to - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Binding socket to address %s:%d ...', strtoupper($this->getSocketProtocol()), $address, $port)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: Binding socket to address %s:%d ...', strtoupper($this->getSocketProtocol()), $address, $port)); $result = socket_bind($this->getSocketResource(), $address, $port); // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); return $result; } @@ -568,7 +568,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function listenToSocket () { // Should be valid socket - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); if (!$this->isValidSocket()) { // Throw exception throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); @@ -578,7 +578,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $result = socket_listen($this->getSocketResource(), self::$configEntries[sprintf('%s_socket_listen_backlog', $this->getSocketType())]); // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); return $result; } @@ -590,7 +590,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function enableSocketNonBlocking () { // Should be valid socket - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); if (!$this->isValidSocket()) { // Throw exception throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); @@ -600,7 +600,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $result = socket_set_nonblock($this->getSocketResource()); // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); return $result; } @@ -612,7 +612,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function enableSocketReuseAddress () { // Should be valid socket - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); if (!$this->isValidSocket()) { // Throw exception throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); @@ -622,7 +622,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $result = $this->setSocketOption(SOL_SOCKET, SO_REUSEADDR, 1); // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); return $result; } @@ -634,7 +634,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function connectToSocketRecipient () { // Should be valid socket - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); if (!$this->isValidSocket()) { // Throw exception throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); @@ -644,15 +644,15 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $unlRecipient = $this->getSocketRecipientUnl(); // Create UNL instance from it. This will validate the connection - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unlRecipient=%s', strtoupper($this->getSocketProtocol()), $unlRecipient)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: unlRecipient=%s', strtoupper($this->getSocketProtocol()), $unlRecipient)); $locatorInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($unlRecipient); // Try to connect to it - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unlAddress=%s,unlPort=%d', strtoupper($this->getSocketProtocol()), $locatorInstance->getUnlAddress(), $locatorInstance->getUnlPort())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: unlAddress=%s,unlPort=%d', strtoupper($this->getSocketProtocol()), $locatorInstance->getUnlAddress(), $locatorInstance->getUnlPort())); $result = socket_connect($this->getSocketResource(), $locatorInstance->getUnlAddress(), $locatorInstance->getUnlPort()); // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); return $result; } @@ -667,14 +667,14 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function doShutdown () { // Should be valid socket - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); if (!$this->isValidSocket()) { // Throw exception throw new BadMethodCallException(sprintf('[%s:%d]: Shutdown on invalid socket. Maybe called already?', __METHOD__, __LINE__), self::EXCEPTION_INVALID_SOCKET, FrameworkInterface::EXCEPTION_BAD_METHOD_CALL); } // Debug message - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Shutting down socket ' . $this->getSocketResource()); + self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(strtoupper($this->getSocketProtocol()) . '-SOCKET: Shutting down socket ' . $this->getSocketResource()); DebugMiddleware::getSelfInstance()->partialStub('Please rewrite this method.'); return; @@ -703,7 +703,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $this->markConnectionShuttedDown(); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: EXIT!', strtoupper($this->getSocketProtocol()))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: EXIT!', strtoupper($this->getSocketProtocol()))); } /** @@ -715,7 +715,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function isValidConnectionType (string $connectionType) { // Validate parameter - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: connectionType=%d - CALLED!', strtoupper($this->getSocketProtocol()), $connectionType)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: connectionType=%d - CALLED!', strtoupper($this->getSocketProtocol()), $connectionType)); if (empty($connectionType)) { // Throw exception throw new InvalidArgumentException('connectionType is empty'); @@ -725,7 +725,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $isValid = in_array($connectionType, self::$connectionTypes, TRUE); // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: isValid=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($isValid))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: isValid=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($isValid))); return $isValid; } @@ -737,20 +737,20 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function acceptNewIncomingSocket () { // Should be valid socket - /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); if (!$this->isValidSocket()) { // Throw exception throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); } // Init all arrays, at least readers - /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: this->socketResource=%s', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); $readers = [$this->getSocketResource()]; $writers = []; $excepts = []; // Check if we have some peers left - /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Invoking socket_select(%d,%d,%d,0%d) ...', strtoupper($this->getSocketProtocol()), count($readers), count($writers), count($excepts), self::$configEntries['socket_select_timeout'])); + /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: Invoking socket_select(%d,%d,%d,0%d) ...', strtoupper($this->getSocketProtocol()), count($readers), count($writers), count($excepts), self::$configEntries['socket_select_timeout'])); $left = socket_select( $readers, $writers, @@ -760,14 +760,14 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita ); // Some new peers found? - /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: left=%d,readers()=%d,writers()=%d,except()=%d) ...', strtoupper($this->getSocketProtocol()), $left, count($readers), count($writers), count($excepts))); + /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: left=%d,readers()=%d,writers()=%d,except()=%d) ...', strtoupper($this->getSocketProtocol()), $left, count($readers), count($writers), count($excepts))); if ($left < 1) { // Nothing new found - /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: left=%d,serverSocket=%s,readers()=%d', strtoupper($this->getSocketProtocol()), $left, $this->getSocketResource(), count($readers))); + /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: left=%d,serverSocket=%s,readers()=%d, returning NULL - EXIT!', strtoupper($this->getSocketProtocol()), $left, $this->getSocketResource(), count($readers))); return NULL; } elseif (!in_array($this->getSocketResource(), $readers)) { // Abort here - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: No incoming socket found, returning NULL - EXIT!', strtoupper($this->getSocketProtocol()))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: No incoming socket found, returning NULL - EXIT!', strtoupper($this->getSocketProtocol()))); return NULL; } @@ -781,11 +781,11 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $socketResource = socket_accept($this->getSocketResource()); // Create socket instance from it - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s,serverSocket=%s', strtoupper($this->getSocketProtocol()), $socketResource, $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: this->socketResource=%s,serverSocket=%s', strtoupper($this->getSocketProtocol()), $socketResource, $this->getSocketResource())); $socketInstance = SocketFactory::createIncomingSocketInstance($socketResource, $this->getSocketProtocol()); // Return accepted socket instance - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketInstance=%s - EXIT!', strtoupper($this->getSocketProtocol()), $socketInstance->__toString())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: socketInstance=%s - EXIT!', strtoupper($this->getSocketProtocol()), $socketInstance->__toString())); return $socketInstance; } @@ -797,7 +797,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function readDataFromSocket () { // Should be valid socket - /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); if (!$this->isValidSocket()) { // Throw exception throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); @@ -811,7 +811,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $rawData = socket_read($this->getSocketResource(), FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('tcp_buffer_length'), PHP_BINARY_READ); // Return it - /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s,rawData[%s]=%s - EXIT!', strtoupper($this->getSocketProtocol()), $this->getSocketResource(), gettype($rawData), $rawData)); + /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s,rawData[%s]=%s - EXIT!', strtoupper($this->getSocketProtocol()), $this->getSocketResource(), gettype($rawData), $rawData)); return $rawData; } @@ -823,7 +823,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function identifySocketPeer () { // Init peer address (IP)/port - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); $peerAddress = '0.0.0.0'; $peerPort = 0; @@ -831,7 +831,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $result = $this->determineSocketPeerName($peerAddress, $peerPort); // Valid? - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d,peerAddress[%s]=%s,peerPort[%s]=%d', strtoupper($this->getSocketProtocol()), intval($result), gettype($peerAddress), $peerAddress, gettype($peerPort), $peerPort)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: result=%d,peerAddress[%s]=%s,peerPort[%s]=%d', strtoupper($this->getSocketProtocol()), intval($result), gettype($peerAddress), $peerAddress, gettype($peerPort), $peerPort)); if ($result === TRUE) { // Set both $this->setPeerAddress($peerAddress); @@ -839,7 +839,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita } // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); return $result; } @@ -850,7 +850,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function setSocketTimeoutOptions () { // Call setter method with configured values - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); $result = $this->setSocketOption(SOL_SOCKET, SO_RCVTIMEO, [ // Seconds 'sec' => FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($this->getSocketProtocol() . '_socket_accept_wait_sec'), @@ -859,7 +859,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita ]); // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); return $result; } @@ -870,11 +870,11 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function enableSocketOutOfBandData () { // Call inner method - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); $result = $this->setSocketOption(SOL_SOCKET, SO_OOBINLINE, 1); // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); return $result; } @@ -887,7 +887,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function clearLastSocketError () { // Should be valid socket - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Clearing socket error, this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: Clearing socket error, this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); if (!$this->isValidSocket()) { // Throw exception throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); @@ -900,7 +900,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita socket_clear_error($this->getSocketResource()); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Error cleared - EXIT!', strtoupper($this->getSocketProtocol()))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: Error cleared - EXIT!', strtoupper($this->getSocketProtocol()))); } /** @@ -912,24 +912,24 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function registerInfoInstance (ShareableInfo $infoInstance) { // Get listener/helper from info class - /* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: infoInstance=%s,this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $infoInstance->__toString(), $this->getSocketResource())); + /* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: infoInstance=%s,this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $infoInstance->__toString(), $this->getSocketResource())); $listenerInstance = $infoInstance->getListenerInstance(); $helperInstance = $infoInstance->getHelperInstance(); // Is there a listener or a connection helper instance set? - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: listenerInstance[]=%s,helperInstance[]=%s', strtoupper($this->getSocketProtocol()), gettype($listenerInstance), gettype($helperInstance))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: listenerInstance[]=%s,helperInstance[]=%s', strtoupper($this->getSocketProtocol()), gettype($listenerInstance), gettype($helperInstance))); if ($listenerInstance instanceof Listenable) { // Set it here for later usage - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Setting listenerInstance=' . $listenerInstance->__toString() . ' ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(strtoupper($this->getSocketProtocol()) . '-SOCKET: Setting listenerInstance=' . $listenerInstance->__toString() . ' ...'); $this->setListenerInstance($listenerInstance); } elseif ($helperInstance instanceof ConnectionHelper) { // Set it here for later usage - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Setting helperInstance=' . $helperInstance->__toString() . ' ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(strtoupper($this->getSocketProtocol()) . '-SOCKET: Setting helperInstance=' . $helperInstance->__toString() . ' ...'); $this->setHelperInstance($helperInstance); } // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: EXIT!', strtoupper($this->getSocketProtocol()))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: EXIT!', strtoupper($this->getSocketProtocol()))); } /** @@ -948,8 +948,8 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function writeBufferToSocketByArray (array &$socketBuffer, &$sentBytes) { // Should be valid socket - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketBuffer()=%d,sentBytes=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketBuffer), $sentBytes)); - //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketBuffer=%s', strtoupper($this->getSocketProtocol()), print_r($socketBuffer, TRUE))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: socketBuffer()=%d,sentBytes=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketBuffer), $sentBytes)); + //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: socketBuffer=%s', strtoupper($this->getSocketProtocol()), print_r($socketBuffer, TRUE))); if (!$this->isValidSocket()) { // Throw exception throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); @@ -971,30 +971,30 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $bufferSize = $socketBuffer[NetworkPackageHandler::RAW_INDEX_BUFFER_SIZE]; // Is some data still pending or sent all out? - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: bufferSize=%d,socketBuffer[%s]=%d', strtoupper($this->getSocketProtocol()), $bufferSize, NetworkPackageHandler::RAW_INDEX_DIFF, $socketBuffer[NetworkPackageHandler::RAW_INDEX_DIFF])); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: bufferSize=%d,socketBuffer[%s]=%d', strtoupper($this->getSocketProtocol()), $bufferSize, NetworkPackageHandler::RAW_INDEX_DIFF, $socketBuffer[NetworkPackageHandler::RAW_INDEX_DIFF])); if ($socketBuffer[NetworkPackageHandler::RAW_INDEX_DIFF] >= 0) { // Reduce buffer size by difference $bufferSize = $socketBuffer[NetworkPackageHandler::RAW_INDEX_BUFFER_SIZE] - $socketBuffer[NetworkPackageHandler::RAW_INDEX_DIFF]; } // Send buffered raw data - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Invoking socket_write(%s,()=%d,%d) ...', strtoupper($this->getSocketProtocol()), $this->getSocketResource(), strlen($socketBuffer[NetworkPackageHandler::RAW_INDEX_ENCODED_DATA]), $bufferSize)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: Invoking socket_write(%s,()=%d,%d) ...', strtoupper($this->getSocketProtocol()), $this->getSocketResource(), strlen($socketBuffer[NetworkPackageHandler::RAW_INDEX_ENCODED_DATA]), $bufferSize)); $sentBytes = socket_write($this->getSocketResource(), $socketBuffer[NetworkPackageHandler::RAW_INDEX_ENCODED_DATA], $bufferSize); // Check if the operation was okay - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: sentBytes[%s]=%d', strtoupper($this->getSocketProtocol()), gettype($sentBytes), $sentBytes)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: sentBytes[%s]=%d', strtoupper($this->getSocketProtocol()), gettype($sentBytes), $sentBytes)); // @TODO Maybe check more? $result = ($sentBytes !== FALSE); // If there was an error, don't continue here - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: sentBytes[%s]=%d,result=%d', strtoupper($this->getSocketProtocol()), gettype($sentBytes), $sentBytes, intval($result))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: sentBytes[%s]=%d,result=%d', strtoupper($this->getSocketProtocol()), gettype($sentBytes), $sentBytes, intval($result))); if ($result === FALSE) { // Failed delivery! - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socket_write() failed, please evaluate. - EXIT!', strtoupper($this->getSocketProtocol()))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: socket_write() failed, please evaluate. - EXIT!', strtoupper($this->getSocketProtocol()))); return FALSE; } elseif (($sentBytes === 0) && (strlen($socketBuffer[NetworkPackageHandler::RAW_INDEX_ENCODED_DATA]) > 0)) { // Nothing sent means all data has been sent - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: All sent, returning TRUE ... - EXIT!', strtoupper($this->getSocketProtocol()))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: All sent, returning TRUE ... - EXIT!', strtoupper($this->getSocketProtocol()))); return TRUE; } else { // The difference between sent bytes and length of raw data should not go below zero @@ -1004,7 +1004,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $socketBuffer[NetworkPackageHandler::RAW_INDEX_SENT_BYTES] += $sentBytes; // Cut out the last unsent bytes - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Sent out %d of %d bytes ...', strtoupper($this->getSocketProtocol()), $sentBytes, strlen($socketBuffer[NetworkPackageHandler::RAW_INDEX_ENCODED_DATA]))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: Sent out %d of %d bytes ...', strtoupper($this->getSocketProtocol()), $sentBytes, strlen($socketBuffer[NetworkPackageHandler::RAW_INDEX_ENCODED_DATA]))); $socketBuffer[NetworkPackageHandler::RAW_INDEX_ENCODED_DATA] = substr($socketBuffer[NetworkPackageHandler::RAW_INDEX_ENCODED_DATA], $sentBytes); // Calculate difference again @@ -1012,7 +1012,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita } // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); return $result; } @@ -1030,7 +1030,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function handleSocketError (string $method, int $line) { // This method handles only socket resources - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: method=%s,line=%d,lastSocketErrorCode=%d - CALLED!', strtoupper($this->getSocketProtocol()), $method, $line, $this->getLastSocketErrorCode())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: method=%s,line=%d,lastSocketErrorCode=%d - CALLED!', strtoupper($this->getSocketProtocol()), $method, $line, $this->getLastSocketErrorCode())); if (!$this->isValidSocket()) { // No resource, abort here throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); @@ -1049,14 +1049,14 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $handlerName = $this->getSocketErrorHandlerFromCode($errorCode); // Call-back the error handler method - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: handlerName=%s', strtoupper($this->getSocketProtocol()), $handlerName)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: handlerName=%s', strtoupper($this->getSocketProtocol()), $handlerName)); call_user_func_array([$this, $handlerName], []); // Finally clear the error because it has been handled $this->clearLastSocketError(); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: EXIT!', strtoupper($this->getSocketProtocol()))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: EXIT!', strtoupper($this->getSocketProtocol()))); } /** @@ -1069,7 +1069,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function getSocketErrorHandlerFromCode (int $errorCode) { // Create a name from translated error code - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorCode=%d - CALLED!', strtoupper($this->getSocketProtocol()), $errorCode)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: errorCode=%d - CALLED!', strtoupper($this->getSocketProtocol()), $errorCode)); $handlerName = 'handleSocketError' . StringUtils::convertToClassName($this->translateSocketErrorCodeToName($errorCode)); // Is the call-back method there? @@ -1079,7 +1079,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita } // Return it - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: handlerName=%d - EXIT!', strtoupper($this->getSocketProtocol()), $handlerName)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: handlerName=%d - EXIT!', strtoupper($this->getSocketProtocol()), $handlerName)); return $handlerName; } @@ -1096,7 +1096,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorPermissionDenied () { // Get socket error code for verification - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); $socketError = $this->getLastSocketErrorCode(); // Get error message @@ -1118,7 +1118,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorConnectionTimedOut () { // Get socket error code for verification - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); $socketError = $this->getLastSocketErrorCode(); // Get error message @@ -1140,7 +1140,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorResourceUnavailable () { // Get socket error code for verification - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); $socketError = $this->getLastSocketErrorCode(); // Get error message @@ -1162,7 +1162,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorConnectionRefused () { // Get socket error code for verification - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); $socketError = $this->getLastSocketErrorCode(); // Get error message @@ -1184,7 +1184,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorNoRouteToHost () { // Get socket error code for verification - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); $socketError = $this->getLastSocketErrorCode(); // Get error message @@ -1206,7 +1206,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorOperationAlreadyProgress () { // Get socket error code for verification - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); $socketError = $this->getLastSocketErrorCode(); // Get error message @@ -1228,7 +1228,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorConnectionResetByPeer () { // Get socket error code for verification - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); $socketError = $this->getLastSocketErrorCode(); // Get error message @@ -1250,7 +1250,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorOperationNotSupported () { // Get socket error code for verification - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); $socketError = $this->getLastSocketErrorCode(); // Get error message @@ -1271,8 +1271,8 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorOperationInProgress () { // Very common with non-blocking I/O - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-HELPER: Operation is now in progress, this is usual for non-blocking connections and is no bug.'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(strtoupper($this->getSocketProtocol()) . '-HELPER: Operation is now in progress, this is usual for non-blocking connections and is no bug.'); } /************************************************************************ @@ -1288,7 +1288,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ private function translateSocketErrorCodeToName (int $errorCode) { // Unknown error code by default - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorCode=%d - CALLED!', strtoupper($this->getSocketProtocol()), $errorCode)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: errorCode=%d - CALLED!', strtoupper($this->getSocketProtocol()), $errorCode)); $errorName = StorableSocket::SOCKET_ERROR_UNKNOWN; // Is the code a number, then we have to change it @@ -1345,12 +1345,12 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita default: // Everything else <> 0 // Unhandled error code detected, so first debug it because we may want to handle it like the others - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf(strtoupper($this->getSocketProtocol()) . '-SOCKET: Unsupported errorCode=%d,message=%s', $errorCode, socket_strerror($errorCode))); + self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf(strtoupper($this->getSocketProtocol()) . '-SOCKET: Unsupported errorCode=%d,message=%s', $errorCode, socket_strerror($errorCode))); break; } // Return translated name - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorName=%s - EXIT!', strtoupper($this->getSocketProtocol()), $errorName)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: errorName=%s - EXIT!', strtoupper($this->getSocketProtocol()), $errorName)); return $errorName; } @@ -1365,7 +1365,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ private function setSocketOption (int $level, int $optionName, $optionValue) { // Should be valid socket - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: level=%d,optionName=%d,optionValue[]=%s - CALLED!', strtoupper($this->getSocketProtocol()), $level, $optionName, gettype($optionValue))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: level=%d,optionName=%d,optionValue[]=%s - CALLED!', strtoupper($this->getSocketProtocol()), $level, $optionName, gettype($optionValue))); if (!$this->isValidSocket()) { // Throw exception throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET); @@ -1375,7 +1375,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $result = socket_set_option($this->getSocketResource(), $level, $optionName, $optionValue); // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); return $result; } -- 2.39.5