]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 26 Jan 2025 16:09:50 +0000 (17:09 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 26 Jan 2025 16:09:50 +0000 (17:09 +0100)
- renamed variable
- socket "resource" is since PHP 8.0 a class Socket

application/hub/classes/container/socket/class_SocketContainer.php
application/hub/classes/registry/socket/class_SocketRegistry.php

index 8619967bd1acdf1c1d8cb658fc3ddd6ced258c33..7fb5554759a40c1f2d77b5a7eb483e675b093b20 100644 (file)
@@ -153,7 +153,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         * @param       $socketProtocol         Socket protocol (TCP, UDP, file)
         * @param       $packageInstance        An instance of a DeliverablePackage class
         * @param       $socketType                     Socket type (incoming, outgoing, server, file, ...)
-        * @return      $socketInstance         An instance of a StorableSocket class
+        * @return      $containerInstance      An instance of a StorableSocket class
         * @throws      InvalidArgumentException        If a parameter is not valid
         */
        public static final function createSocketContainer (Socket $socketResource, string $socketProtocol, DeliverablePackage $packageInstance, string $socketType) {
@@ -168,20 +168,20 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
                }
 
                // Get a new instance
-               $socketInstance = new SocketContainer();
+               $containerInstance = new SocketContainer();
 
                // Set all values
-               $socketInstance->setSocketProtocol($socketProtocol);
-               $socketInstance->setSocketResource($socketResource);
-               $socketInstance->setPackageDataInstance($packageInstance);
-               $socketInstance->setSocketType($socketType);
+               $containerInstance->setSocketProtocol($socketProtocol);
+               $containerInstance->setSocketResource($socketResource);
+               $containerInstance->setPackageDataInstance($packageInstance);
+               $containerInstance->setSocketType($socketType);
 
                // Set more configuration entries
-               self::$configEntries[sprintf('%s_socket_listen_backlog', $socketInstance->getSocketType())] = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry(sprintf('%s_socket_listen_backlog', $socketInstance->getSocketProtocol()));
+               self::$configEntries[sprintf('%s_socket_listen_backlog', $containerInstance->getSocketType())] = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry(sprintf('%s_socket_listen_backlog', $containerInstance->getSocketProtocol()));
 
                // Return the prepared instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: socketInstance=%s - EXIT!', strtoupper($socketProtocol), $socketInstance->__toString()));
-               return $socketInstance;
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: containerInstance=%s - EXIT!', strtoupper($socketProtocol), $containerInstance->__toString()));
+               return $containerInstance;
        }
 
        /**
@@ -238,7 +238,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function shutdownSocket () {
                // Debug message
-               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(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->getPrintableName() . ' with state ' . ($this->getHelperInstance() instanceof Helper ? $this->getHelperInstance()->getPrintableState() : 'NULL') . ' ...');
 
                // Get a visitor instance
                $visitorInstance = ObjectFactory::createObjectByConfiguredName('shutdown_socket_visitor_class');
@@ -261,7 +261,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function halfShutdownSocket () {
                // Debug message
-               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(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->getPrintableName() . ' with state ' . $this->getHelperInstance()->getPrintableState() . ' ...');
 
                // Get a visitor instance
                $visitorInstance = ObjectFactory::createObjectByConfiguredName('half_shutdown_socket_visitor_class');
@@ -347,7 +347,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function getSocketRecipientUnl () {
                // Should be valid socket
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                if (!$this->isValidSocket()) {
                        // Throw exception
                        throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET);
@@ -369,7 +369,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function getSocketRecipientAddress () {
                // Should be valid socket
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                if (!$this->isValidSocket()) {
                        // Throw exception
                        throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET);
@@ -398,7 +398,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function getSocketRecipientPort () {
                // Should be valid socket
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                if (!$this->isValidSocket()) {
                        // Throw exception
                        throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET);
@@ -426,9 +426,9 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function isValidSocket () {
                // Is it valid?
-               //* 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()));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: this->socketResource=%s - CALLED!', strtoupper($this->getSocketProtocol()), $this->getPrintableName()));
+               // @TODO maybe add more checks? instanceof is still to less
+               $isValidSocket = ($this->getSocketResource() instanceof Socket);
 
                // Return status
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-SOCKET: isValidSocket=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($isValidSocket)));
@@ -443,7 +443,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function getLastSocketErrorCode () {
                // Should be valid socket
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                if (!$this->isValidSocket()) {
                        // Throw exception
                        throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET);
@@ -465,7 +465,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function getLastSocketErrorMessage () {
                // Should be valid socket
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                if (!$this->isValidSocket()) {
                        // Throw exception
                        throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET);
@@ -486,7 +486,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function translateLastSocketErrorCodeToName () {
                // Get last error code
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                $errorCode = $this->getLastSocketErrorCode();
 
                // Call "translate" method
@@ -507,7 +507,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function bindSocketToFile () {
                // Should be valid socket
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                if (!$this->isValidSocket()) {
                        // Throw exception
                        throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET);
@@ -536,7 +536,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function bindSocketToListener () {
                // Should be valid socket
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                if (!$this->isValidSocket()) {
                        // Throw exception
                        throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET);
@@ -566,7 +566,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function listenToSocket () {
                // Should be valid socket
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                if (!$this->isValidSocket()) {
                        // Throw exception
                        throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET);
@@ -588,7 +588,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function enableSocketNonBlocking () {
                // Should be valid socket
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                if (!$this->isValidSocket()) {
                        // Throw exception
                        throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET);
@@ -610,7 +610,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function enableSocketReuseAddress () {
                // Should be valid socket
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                if (!$this->isValidSocket()) {
                        // Throw exception
                        throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET);
@@ -632,7 +632,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function connectToSocketRecipient () {
                // Should be valid socket
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                if (!$this->isValidSocket()) {
                        // Throw exception
                        throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET);
@@ -665,14 +665,14 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function doShutdown () {
                // Should be valid socket
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                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__)->debugMessage(strtoupper($this->getSocketProtocol()) . '-SOCKET: Shutting down socket ' . $this->getSocketResource());
+               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(strtoupper($this->getSocketProtocol()) . '-SOCKET: Shutting down socket ' . $this->getPrintableName());
                DebugMiddleware::getSelfInstance()->partialStub('Please rewrite this method.');
                return;
 
@@ -735,14 +735,14 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function acceptNewIncomingSocket () {
                // Should be valid socket
-               /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                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__)->debugMessage(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->getPrintableName()));
                $readers = [$this->getSocketResource()];
                $writers = [];
                $excepts = [];
@@ -761,7 +761,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
                /* 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__)->traceMessage(sprintf('%s-SOCKET: left=%d,serverSocket=%s,readers()=%d, returning NULL - EXIT!', 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->getPrintableName(), count($readers)));
                        return NULL;
                } elseif (!in_array($this->getSocketResource(), $readers)) {
                        // Abort here
@@ -779,7 +779,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
                $socketResource = socket_accept($this->getSocketResource());
 
                // Create socket instance from it
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: this->socketResource[]=%s,serverSocket=%s', strtoupper($this->getSocketProtocol()), gettype($socketResource), $this->getSocketResource()));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: this->socketResource[]=%s,serverSocket=%s', strtoupper($this->getSocketProtocol()), gettype($socketResource), $this->getPrintableName()));
                $socketInstance = SocketFactory::createIncomingSocketInstance($socketResource, $this->getSocketProtocol());
 
                // Return accepted socket instance
@@ -795,7 +795,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function readDataFromSocket () {
                // Should be valid socket
-               /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                if (!$this->isValidSocket()) {
                        // Throw exception
                        throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET);
@@ -809,7 +809,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__)->traceMessage(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->getPrintableName(), gettype($rawData), $rawData));
                return $rawData;
        }
 
@@ -821,7 +821,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function identifySocketPeer () {
                // Init peer address (IP)/port
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                $peerAddress = '0.0.0.0';
                $peerPort    = 0;
 
@@ -848,7 +848,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function setSocketTimeoutOptions () {
                // Call setter method with configured values
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                $result = $this->setSocketOption(SOL_SOCKET, SO_RCVTIMEO, [
                        // Seconds
                        'sec'  => FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($this->getSocketProtocol() . '_socket_accept_wait_sec'),
@@ -868,7 +868,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function enableSocketOutOfBandData () {
                // Call inner method
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                $result = $this->setSocketOption(SOL_SOCKET, SO_OOBINLINE, 1);
 
                // Return result
@@ -885,7 +885,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function clearLastSocketError () {
                // Should be valid socket
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                if (!$this->isValidSocket()) {
                        // Throw exception
                        throw new InvalidSocketException([$this], self::EXCEPTION_INVALID_SOCKET);
@@ -910,7 +910,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function registerInfoInstance (ShareableInfo $infoInstance) {
                // Get listener/helper from info class
-               /* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                $listenerInstance = $infoInstance->getListenerInstance();
                $helperInstance = $infoInstance->getHelperInstance();
 
@@ -976,7 +976,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
                }
 
                // Send buffered raw data
-               /* 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));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('%s-SOCKET: Invoking socket_write(%s,()=%d,%d) ...', strtoupper($this->getSocketProtocol()), $this->getPrintableName(), 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
@@ -1094,7 +1094,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        protected function handleSocketErrorPermissionDenied () {
                // Get socket error code for verification
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                $socketError = $this->getLastSocketErrorCode();
 
                // Get error message
@@ -1116,7 +1116,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        protected function handleSocketErrorConnectionTimedOut () {
                // Get socket error code for verification
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                $socketError = $this->getLastSocketErrorCode();
 
                // Get error message
@@ -1138,7 +1138,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        protected function handleSocketErrorResourceUnavailable () {
                // Get socket error code for verification
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                $socketError = $this->getLastSocketErrorCode();
 
                // Get error message
@@ -1160,7 +1160,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        protected function handleSocketErrorConnectionRefused () {
                // Get socket error code for verification
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                $socketError = $this->getLastSocketErrorCode();
 
                // Get error message
@@ -1182,7 +1182,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        protected function handleSocketErrorNoRouteToHost () {
                // Get socket error code for verification
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                $socketError = $this->getLastSocketErrorCode();
 
                // Get error message
@@ -1204,7 +1204,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        protected function handleSocketErrorOperationAlreadyProgress () {
                // Get socket error code for verification
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                $socketError = $this->getLastSocketErrorCode();
 
                // Get error message
@@ -1226,7 +1226,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        protected function handleSocketErrorConnectionResetByPeer () {
                // Get socket error code for verification
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                $socketError = $this->getLastSocketErrorCode();
 
                // Get error message
@@ -1248,7 +1248,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        protected function handleSocketErrorOperationNotSupported () {
                // Get socket error code for verification
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                $socketError = $this->getLastSocketErrorCode();
 
                // Get error message
@@ -1269,7 +1269,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        protected function handleSocketErrorOperationInProgress () {
                // Very common with non-blocking I/O
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(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->getPrintableName()));
                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.');
        }
 
index c86eb9134ec581a15f11987a803e69db2fc58c71..67f983896001dbe11314c8c1a2e1c8374ae9895d 100644 (file)
@@ -180,7 +180,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
         */
        public function isSocketRegistered (ShareableInfo $infoInstance, StorableSocket $socketInstance) {
                // Default is not registered
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ' - CALLED!');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getPrintableName() . ' - CALLED!');
                $isRegistered = FALSE;
 
                // First, check for the instance, there can be only once
@@ -189,14 +189,14 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
                        $key = $this->generateObjectRegistryKeyFromInfoInstance($infoInstance);
 
                        // Get the registry
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',key=' . $key . ' - Trying to get instance ...');
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getPrintableName() . ',key=' . $key . ' - Trying to get instance ...');
                        $registryInstance = self::$registryInstances[$infoInstance->getProtocolName()]->getInstance($key);
 
                        // "Get" a key for the socket
                        $socketKey = $this->generateObjectRegistryKeyFromInfoInstance($infoInstance);
 
                        // Is it there?
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...');
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getPrintableName() . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...');
                        if ($registryInstance->instanceExists($socketKey)) {
                                // Get the instance
                                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-REGISTRY: Found instance for socketKey=' . $socketKey . ':' . $registryInstance->getInstance($socketKey));
@@ -206,12 +206,12 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
                                $isRegistered = (($registeredInstance instanceof StorableSocket) && ($registeredInstance->equals($socketInstance)));
 
                                // Debug message
-                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-REGISTRY: Final result: isRegistered(' . $socketInstance->getSocketResource() . ')=' . intval($isRegistered));
+                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('SOCKET-REGISTRY: Final result: isRegistered(' . $socketInstance->getPrintableName() . ')=' . intval($isRegistered));
                        }
                }
 
                // Return the result
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getPrintableName() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
                return $isRegistered;
        }
 
@@ -225,7 +225,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
         */
        public function registerSocketInstance (ShareableInfo $infoInstance, StorableSocket $socketInstance) {
                // Is the socket already registered?
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SOCKET-REGISTRY: infoInstance->protocolName=%s,infoInstance->socketResource[%s]=%s - CALLED!', $infoInstance->getProtocolName(), gettype($socketInstance->getSocketResource()), $socketInstance->getSocketResource()));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('SOCKET-REGISTRY: infoInstance->protocolName=%s,infoInstance->socketResource[%s]=%s - CALLED!', $infoInstance->getProtocolName(), gettype($socketInstance->getSocketResource()), $socketInstance->getPrintableName()));
                if ($this->isSocketRegistered($infoInstance, $socketInstance)) {
                        // Throw the exception
                        throw new SocketAlreadyRegisteredException(array($infoInstance, $socketInstance->getSocketResource()), BaseListener::EXCEPTION_SOCKET_ALREADY_REGISTERED);