]> git.mxchange.org Git - hub.git/commitdiff
Moved some socket initializations before socket_bind(), made setErrorCode() public
authorRoland Häder <roland@mxchange.org>
Fri, 18 May 2012 22:07:10 +0000 (22:07 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 18 May 2012 22:07:10 +0000 (22:07 +0000)
application/hub/main/handler/network/class_BaseRawDataHandler.php
application/hub/main/listener/tcp/class_TcpListener.php

index 9a3cc31b8c6ea582174244a1acda6f0126aacf6b..1fc3cde761916ec7d81a6371e9bb5f39cc73ff95 100644 (file)
@@ -165,7 +165,7 @@ class BaseRawDataHandler extends BaseHandler {
         * @param       $errorCode      The error code we shall set
         * @return      void
         */
-       protected final function setErrorCode ($errorCode) {
+       public final function setErrorCode ($errorCode) {
                $this->errorCode = $errorCode;
        }
 
index 2f6a3224a5eac209b85184faf92872870f463d0b..abab91478e8dd51d5282118e962807ac6fab0477 100644 (file)
@@ -100,11 +100,9 @@ class TcpListener extends BaseListener implements Listenable {
                        */
                } // END - if
 
-               // "Bind" the socket to the given address, on given port so this means
-               // that all connections on this port are now our resposibility to
-               // send/recv data, disconnect, etc..
-               $this->debugOutput('TCP-LISTENER: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort());
-               if (!socket_bind($mainSocket, $this->getListenAddress(), $this->getListenPort())) {
+               // Now, we want non-blocking mode
+               $this->debugOutput('TCP-LISTENER: Setting non-blocking mode.');
+               if (!socket_set_nonblock($mainSocket)) {
                        // Handle this socket error with a faked recipientData array
                        $this->handleSocketError($mainSocket, array('0.0.0.0', '0'));
                        /*
@@ -122,9 +120,13 @@ class TcpListener extends BaseListener implements Listenable {
                        */
                } // END - if
 
-               // Start listen for connections
-               $this->debugOutput('TCP-LISTENER: Listening for connections.');
-               if (!socket_listen($mainSocket)) {
+               /*
+                * "Bind" the socket to the given address, on given port so this means
+                * that all connections on this port are now our resposibility to
+                * send/recv data, disconnect, etc..
+                */
+               $this->debugOutput('TCP-LISTENER: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort());
+               if (!socket_bind($mainSocket, $this->getListenAddress(), $this->getListenPort())) {
                        // Handle this socket error with a faked recipientData array
                        $this->handleSocketError($mainSocket, array('0.0.0.0', '0'));
                        /*
@@ -142,9 +144,9 @@ class TcpListener extends BaseListener implements Listenable {
                        */
                } // END - if
 
-               // Now, we want non-blocking mode
-               $this->debugOutput('TCP-LISTENER: Setting non-blocking mode.');
-               if (!socket_set_nonblock($mainSocket)) {
+               // Start listen for connections
+               $this->debugOutput('TCP-LISTENER: Listening for connections.');
+               if (!socket_listen($mainSocket)) {
                        // Handle this socket error with a faked recipientData array
                        $this->handleSocketError($mainSocket, array('0.0.0.0', '0'));
                        /*