]> git.mxchange.org Git - hub.git/commitdiff
Continued a bit:
authorRoland Häder <roland@mxchange.org>
Sat, 20 May 2017 19:58:07 +0000 (21:58 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 21 Aug 2020 16:50:04 +0000 (18:50 +0200)
- implemented getLastSocketError()
- added partial stub for bindSocketTo()

Signed-off-by: Roland Häder <roland@mxchange.org>
application/hub/classes/container/socket/class_SocketContainer.php
application/hub/classes/factories/socket/class_SocketFactory.php
application/hub/interfaces/container/socket/class_StorableSocket.php

index 051f56f098b7aea5ad14bec50f0d5673cfe78ff6..b23195fcd5940715e1d66e1fb06a3c088197f452 100644 (file)
@@ -4,12 +4,14 @@ namespace Hub\Container\Socket;
 
 // Import application-specific stuff
 use Hub\Information\ShareableInfo;
+use Hub\Listener\BaseListener;
 use Hub\Network\Package\NetworkPackage;
 
 // Import framework stuff
 use CoreFramework\Container\BaseContainer;
 use CoreFramework\Listener\Listenable;
 use CoreFramework\Registry\Registerable;
+use CoreFramework\Socket\InvalidSocketException;
 use CoreFramework\Visitor\Visitable;
 use CoreFramework\Visitor\Visitor;
 
@@ -240,4 +242,35 @@ class SocketContainer extends BaseContainer implements StorableSocket, Visitable
                return $isValidSocket;
        }
 
+       /**
+        * Getter for last socket error
+        *
+        * @return      $lastSocketError        Last socket error
+        */
+       public function getLastSocketError () {
+               // Should be valid socket
+               if (!$this->isValidSocket()) {
+                       // Throw exception
+                       throw new InvalidSocketException(array($this, $this->getSocketResource()), BaseListener::EXCEPTION_INVALID_SOCKET);
+               } // END - if
+
+               // Get it from stored socket resource
+               $socketResource = $this->getSocketResource();
+
+               // Get error code
+               $errorCode = socket_last_error($socketResource);
+
+               // Return it
+               return $errorCode;
+       }
+
+       /**
+        * Tries to bind the socket.
+        *
+        * @return      $result         Result from binding socket
+        */
+       public function bindSocketTo () {
+               $this->partialStub('Unfinished method.');
+       }
+
 }
index dfacab06b3b950dfadc8277175e3200afe16bd80..18035de30016248fe5f172fda0dfe0cbbd6317f8 100644 (file)
@@ -178,7 +178,7 @@ class SocketFactory extends ObjectFactory {
                        $listenerInstance->handleSocketError(__METHOD__, __LINE__, $socketInstance, $packageData);
                } // END - if
 
-               // Now, we want non-blocking mode
+               // Allow non-blocking I/O
                self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Setting non-blocking mode.');
                if (!$socketInstance->enableSocketNonBlocking()) {
                        // Handle this socket error with a faked recipientData array
index 2833ce2a0516b252ea34a853128d858480c7e54b..8f80383c4a6bc1c3937a3c04379984a388689388 100644 (file)
@@ -75,4 +75,18 @@ interface StorableSocket extends FrameworkInterface {
         */
        function isValidSocket ();
 
+       /**
+        * Getter for last socket error
+        *
+        * @return      $lastSocketError        Last socket error
+        */
+       function getLastSocketError ();
+
+       /**
+        * Tries to bind the socket.
+        *
+        * @return      $result         Result from binding socket
+        */
+       function bindSocketTo ();
+
 }