From: Roland Häder Date: Mon, 26 Apr 2010 14:53:24 +0000 (+0000) Subject: Handling of server socket resource basic finished in BaseListener, interfaces added X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3fd3a9c63f118a180da6e19e8f76cb989d74f782;p=hub.git Handling of server socket resource basic finished in BaseListener, interfaces added --- diff --git a/application/hub/config.php b/application/hub/config.php index 6f485e8f9..d7b5a92eb 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -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] ?> diff --git a/application/hub/interfaces/protocol/class_ProtocolHandler.php b/application/hub/interfaces/protocol/class_ProtocolHandler.php index ac3d799e9..dd4c472c2 100644 --- a/application/hub/interfaces/protocol/class_ProtocolHandler.php +++ b/application/hub/interfaces/protocol/class_ProtocolHandler.php @@ -22,6 +22,26 @@ * along with this program. If not, see . */ 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] diff --git a/application/hub/main/listener/class_ b/application/hub/main/listener/class_ index 546266a21..031484049 100644 --- a/application/hub/main/listener/class_ +++ b/application/hub/main/listener/class_ @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class ???Listener extends BaseListener implements Listenable, Visitable { +class ???Listener extends BaseListener implements Listenable { /** * Protected constructor * diff --git a/application/hub/main/listener/class_BaseListener.php b/application/hub/main/listener/class_BaseListener.php index de796756e..7bbf70b00 100644 --- a/application/hub/main/listener/class_BaseListener.php +++ b/application/hub/main/listener/class_BaseListener.php @@ -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; diff --git a/application/hub/main/listener/class_BaseListenerDecorator.php b/application/hub/main/listener/class_BaseListenerDecorator.php index 5b9889e20..953c131cd 100644 --- a/application/hub/main/listener/class_BaseListenerDecorator.php +++ b/application/hub/main/listener/class_BaseListenerDecorator.php @@ -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 * diff --git a/application/hub/main/listener/udp/class_ b/application/hub/main/listener/udp/class_ index 4dda18d8c..16fda4749 100644 --- a/application/hub/main/listener/udp/class_ +++ b/application/hub/main/listener/udp/class_ @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class Udp???Listener extends BaseListener implements Listenable, Visitable { +class Udp???Listener extends BaseListener implements Listenable { /** * Protected constructor *