]> git.mxchange.org Git - hub.git/commitdiff
Handling of server socket resource basic finished in BaseListener, interfaces added
authorRoland Häder <roland@mxchange.org>
Mon, 26 Apr 2010 14:53:24 +0000 (14:53 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 26 Apr 2010 14:53:24 +0000 (14:53 +0000)
application/hub/config.php
application/hub/interfaces/protocol/class_ProtocolHandler.php
application/hub/main/listener/class_
application/hub/main/listener/class_BaseListener.php
application/hub/main/listener/class_BaseListenerDecorator.php
application/hub/main/listener/udp/class_

index 6f485e8f93317d4fff25cdfd9a4f305a86f6b9e4..d7b5a92eb799fddf37b8862c8e41bc79e2937ccc 100644 (file)
@@ -351,5 +351,8 @@ $cfg->setConfigEntry('hub_list_class', 'HubList');
 // CFG: SOCKET-REGISTRY-CLASS
 $cfg->setConfigEntry('socket_registry_class', 'SocketRegistry');
 
+// CFG: SOCKET-CONTAINER-CLASS
+$cfg->setConfigEntry('socket_container_class', 'SocketContainer');
+
 // [EOF]
 ?>
index ac3d799e9841027691fbf4ef75473aa2f128c66a..dd4c472c2cfc63c2ad702b62be32adc895c28df2 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 interface ProtocolHandler extends FrameworkInterface {
+       /**
+        * Getter for port number to satify ProtocolHandler
+        *
+        * @return      $port   The port number
+        */
+       function getPort ();
+
+       /**
+        * Getter for protocol
+        *
+        * @return      $protocol       Used protocol
+        */
+       function getProtocol ();
+
+       /**
+        * Getter for "this" socket resource
+        *
+        * @return      $socketResource         A valid socket resource
+        */
+       function getSocketResource ();
 }
 
 // [EOF]
index 546266a21bec9559d552deb2891fb6eec71c248d..031484049aa3a5c541da6536aad4dbbfcc70a939 100644 (file)
@@ -21,7 +21,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-class ???Listener extends BaseListener implements Listenable, Visitable {
+class ???Listener extends BaseListener implements Listenable {
        /**
         * Protected constructor
         *
index de796756ea1ade49402c491469b5f756de17ded9..7bbf70b00241e819b840ba65ba7949fcd476e0a1 100644 (file)
@@ -77,8 +77,11 @@ class BaseListener extends BaseHubSystem implements Visitable {
                // Check it
                $isServerSocket = ((is_resource($socketResource)) && (!@socket_getpeername($socketResource, $peerName)));
 
-               // We need to clear the error here
-               socket_clear_error($socketResource);
+               // We need to clear the error here if it is a resource
+               if ($isServerSocket === true) {
+                       // Clear the error
+                       socket_clear_error($socketResource);
+               } // END - if
 
                // Check peer name, it must be empty
                $isServerSocket = (($isServerSocket) && (empty($peerName)));
@@ -125,6 +128,15 @@ class BaseListener extends BaseHubSystem implements Visitable {
                return $this->listenPort;
        }
 
+       /**
+        * Getter for port number to satify ProtocolHandler
+        *
+        * @return      $port   The port number
+        */
+       public final function getPort () {
+               return $this->getListenPort();
+       }
+
        /**
         * "Setter" to set listen address from configuration entry
         *
@@ -275,7 +287,7 @@ class BaseListener extends BaseHubSystem implements Visitable {
                $registryInstance = SocketRegistryFactory::createSocketRegistryInstance();
 
                // Get the socket resource
-               $socketResource = $registryInstance->getSocketResource($this);
+               $socketResource = $registryInstance->getRegisteredSocketResource($this);
 
                // Return it
                return $socketResource;
index 5b9889e202c4d663c5d8003fd21f2dd0d5325444..953c131cdcfb2d22bd0b595d8314fed2c5df7c8b 100644 (file)
@@ -51,6 +51,15 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable {
                return $this->getListenerInstance()->getListenPort();
        }
 
+       /**
+        * Getter for port
+        *
+        * @return      $port   The port
+        */
+       public final function getPort () {
+               return $this->getListenerInstance()->getPort();
+       }
+
        /**
         * Getter for protocol
         *
index 4dda18d8cf3df64442eec4322d5b9d73e409806d..16fda4749f623d974ca065a05f9b07cfcbe3b075 100644 (file)
@@ -21,7 +21,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-class Udp???Listener extends BaseListener implements Listenable, Visitable {
+class Udp???Listener extends BaseListener implements Listenable {
        /**
         * Protected constructor
         *