From 5179e64e1f410520abc940029f64f713049d1798 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 30 May 2017 17:54:53 +0200 Subject: [PATCH] Continued: - added much more debug lines - UdpListener::initListener() or so, is now rewritten (much untested) - BaseListener::ifListenerAcceptsPackageData() is now implemented and should always be used to check if the package's socket protocol is accepted - imported SocketAlreadyRegisteredException - imported ShareableInfo - imported LogicException (and maybe others) - need to get socket resource from socketInstance - updated core MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../hub/classes/class_BaseHubSystem.php | 1 - .../socket/class_SocketContainer.php | 13 ++- .../socket/class_PackageSocketDiscovery.php | 18 +++- .../factories/socket/class_SocketFactory.php | 14 ++- .../hub/classes/handler/raw_data/class_ | 6 +- .../raw_data/class_BaseRawDataHandler.php | 25 ++++++ .../socket/class_SocketRawDataHandler.php | 10 +-- .../raw_data/tcp/class_TcpRawDataHandler.php | 46 +++++++--- .../raw_data/udp/class_UdpRawDataHandler.php | 31 ++++--- .../classes/listener/class_BaseListener.php | 89 ++++++++++++++++++- .../listener/class_BaseListenerDecorator.php | 7 ++ .../socket/class_SocketFileListener.php | 34 ++++++- .../class_SocketFileListenerDecorator.php | 10 +-- .../listener/tcp/class_TcpListener.php | 6 ++ .../class_ClientTcpListenerDecorator.php | 22 ++++- .../class_HubTcpListenerDecorator.php | 22 ++++- .../listener/udp/class_UdpListener.php | 75 +++++++--------- .../class_ClientUdpListenerDecorator.php | 22 ++++- .../class_HubUdpListenerDecorator.php | 22 ++++- .../classes/package/class_NetworkPackage.php | 9 ++ .../hub/classes/pools/class_BasePool.php | 35 ++++++++ .../pools/peer/class_DefaultPeerPool.php | 22 ++--- .../registry/socket/class_SocketRegistry.php | 3 +- .../class_NetworkPackageReaderTask.php | 3 + .../class_RawDataPoolMonitorVisitor.php | 2 +- .../visitor/tasks/class_ActiveTaskVisitor.php | 2 +- .../class_NoSocketRegisteredException.php | 3 + .../socket/class_SocketShutdownException.php | 3 + .../handler/network/class_Networkable.php | 6 +- core | 2 +- 30 files changed, 438 insertions(+), 125 deletions(-) diff --git a/application/hub/classes/class_BaseHubSystem.php b/application/hub/classes/class_BaseHubSystem.php index 10c9710ec..a4d9b24c9 100644 --- a/application/hub/classes/class_BaseHubSystem.php +++ b/application/hub/classes/class_BaseHubSystem.php @@ -18,7 +18,6 @@ use Hub\Pool\Poolable; // Import framework stuff use CoreFramework\Object\BaseFrameworkSystem; -use CoreFramework\Socket\InvalidSocketException; /** * A general hub system class diff --git a/application/hub/classes/container/socket/class_SocketContainer.php b/application/hub/classes/container/socket/class_SocketContainer.php index b458fd0d8..688ea4cbb 100644 --- a/application/hub/classes/container/socket/class_SocketContainer.php +++ b/application/hub/classes/container/socket/class_SocketContainer.php @@ -706,7 +706,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function acceptNewIncomingSocket () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Should be valid socket if (!$this->isValidSocket()) { @@ -714,11 +714,17 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); } // END - if + // Debug message + /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + // Init all arrays, at least readers $readers = array($this->getSocketResource()); $writers = array(); $excepts = array(); + // Trace message + /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Calling socket_select(%d,%d,%d,0%d) ...', strtoupper($this->getSocketProtocol()), count($readers), count($writers), count($excepts), $this->socketSelectTimeout)); + // Check if we have some peers left $left = socket_select( $readers, @@ -728,9 +734,12 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $this->socketSelectTimeout ); + // Debug message + /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: left=%d,readers()=%d,writers()=%d,except()=%d) ...', strtoupper($this->getSocketProtocol()), $left, count($readers), count($writers), count($excepts))); + // Some new peers found? if ($left < 1) { - // Debug message + // Trace message //* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: left=' . $left . ',serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, true)); // Nothing new found diff --git a/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php b/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php index b34090cdd..64655b1a8 100644 --- a/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php +++ b/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php @@ -21,6 +21,9 @@ use CoreFramework\Registry\Registerable; use CoreFramework\Registry\Registry; use CoreFramework\Socket\InvalidSocketException; +// Import SPL stuff +use \LogicException; + /** * A socket discovery class * @@ -96,6 +99,10 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera // Debug message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: protocolName=' . $protocolName); + // Debugging + //* DEBUG-DIE: */ die(__METHOD__.':poolInstance='.print_r($poolInstance, TRUE)); + //* DEBUG-DIE: */ die(__METHOD__.':poolInstance.arrayFromList('.$protocolName.')='.print_r($poolInstance->getArrayFromList($protocolName), TRUE)); + /* * Now we need to choose again. It is whether we are speaking with a hub * or with a client. So just handle it over to all listeners in this @@ -108,10 +115,13 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera // Make sure the instance is valid assert($listenerInstance instanceof Listenable); + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-DISCOVERY: Calling listenerInstance->ifListenerAcceptsPackageData(%d) ...', count($packageData))); + // Does the listener want that package? if ($listenerInstance->ifListenerAcceptsPackageData($packageData)) { // This listener likes our package data, so abort here - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: Listener is accepting package data.'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-DISCOVERY: Listener "%s" is accepting package data.', $listenerInstance->__toString())); break; } // END - if @@ -136,6 +146,7 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera * @throws NoListGroupException If the procol group is not found in peer list * @throws NullPointerException If listenerInstance is NULL * @throws InvalidUnlException If the provided UNL cannot be validated by the protocol handler + * @throws LogicException If the discovered listener instance has no pool set */ public function discoverSocket (array $packageData, $connectionType) { // Debug message @@ -170,7 +181,10 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera if (is_null($listenerInstance)) { // Abort with no resource throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } // END - if + } elseif (is_null($listenerInstance->getPoolInstance())) { + // Opps another one + throw new LogicException(sprintf('listenerInstance=%s has no poolInstance set.', $listenerInstance->__toString()), self::EXCEPTION_IS_NULL_POINTER); + } /* * Now we have the listener instance, we can determine the right diff --git a/application/hub/classes/factories/socket/class_SocketFactory.php b/application/hub/classes/factories/socket/class_SocketFactory.php index 5e35ab2b8..beb2b2003 100644 --- a/application/hub/classes/factories/socket/class_SocketFactory.php +++ b/application/hub/classes/factories/socket/class_SocketFactory.php @@ -132,7 +132,7 @@ class SocketFactory extends ObjectFactory { $socketInstance = self::createObjectByConfiguredName('socket_container_class', array($socketResource, StorableSocket::SOCKET_PROTOCOL_FILE, $packageData)); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FILE_LISTENER: socketInstance[]=%s', gettype($socketInstance))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance[]=%s', gettype($socketInstance))); // Is the socket resource valid? if (!$socketInstance->isValidSocket()) { @@ -256,6 +256,9 @@ class SocketFactory extends ObjectFactory { * @throws InvalidSocketException Thrown if the socket could not be initialized */ public static function createListenTcpSocket (Listenable $listenerInstance) { + // Trace message + /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: listenerInstance=%s - CALLED!', $listenerInstance->__toString())); + // Create a streaming socket, of type TCP/IP $socketResource = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); @@ -327,6 +330,9 @@ class SocketFactory extends ObjectFactory { * @throws InvalidSocketException Thrown if the socket could not be initialized */ public static function createListenUdpSocket (Listenable $listenerInstance) { + // Trace message + /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: listenerInstance=%s - CALLED!', $listenerInstance->__toString())); + // Create a streaming socket, of type TCP/IP $socketResource = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); @@ -394,6 +400,9 @@ class SocketFactory extends ObjectFactory { * @throws LogicException If the current instance is not valid */ public static final function createNextAcceptedSocketFromPool (Poolable $poolInstance, StorableSocket $socketInstance) { + // Trace message + /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: poolInstance=%s,socketInstance.socketResource=%s - CALLED!', $poolInstance->__toString(), $socketInstance->getSocketResource())); + // Is the an iterator instance? if (!Registry::getRegistry()->instanceExists('pool_iterator')) { // Create iterator instance @@ -433,6 +442,9 @@ class SocketFactory extends ObjectFactory { // Try to accept a new (incoming) socket from current listener instance $acceptedSocketInstance = $current[Poolable::SOCKET_ARRAY_INSTANCE]->acceptNewIncomingSocket(); + // Trace message + /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: acceptedSocketInstance[]=%s - EXIT!', gettype($acceptedSocketInstance))); + // Return found socket instance return $acceptedSocketInstance; } diff --git a/application/hub/classes/handler/raw_data/class_ b/application/hub/classes/handler/raw_data/class_ index 0b5036feb..5ddd84547 100644 --- a/application/hub/classes/handler/raw_data/class_ +++ b/application/hub/classes/handler/raw_data/class_ @@ -56,13 +56,13 @@ class ???RawDataHandler extends BaseRawDataHandler implements Networkable { } /** - * Processes raw data from given resource. This is mostly useful for TCP - * package handling and is implemented in the ???Listener class + * Processes raw data from given socket instance. This is mostly useful for + * ||| package handling and is implemented in the ???Listener class. * * @param $resource A valid socket resource array * @return void */ - public function processRawDataFromResource (array $socketArray) { + public function processRawDataFromSocketArray (array $socketArray) { } } diff --git a/application/hub/classes/handler/raw_data/class_BaseRawDataHandler.php b/application/hub/classes/handler/raw_data/class_BaseRawDataHandler.php index b05eb66e1..f58638c2f 100644 --- a/application/hub/classes/handler/raw_data/class_BaseRawDataHandler.php +++ b/application/hub/classes/handler/raw_data/class_BaseRawDataHandler.php @@ -90,7 +90,14 @@ class BaseRawDataHandler extends BaseHubHandler implements HubInterface { * @return void */ protected function initStack () { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: CALLED!'); + + // Init stack(s) $this->getStackInstance()->initStack(self::STACKER_NAME_RAW_DATA); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: EXIT!'); } /** @@ -100,6 +107,9 @@ class BaseRawDataHandler extends BaseHubHandler implements HubInterface { * @return void */ protected function addRawDataToStacker ($rawData) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: rawData()=%d - CALLED!', strlen($rawData))); + /* * Add the deocoded data and error code to the stacker so other classes * (e.g. NetworkPackage) can "pop" it from the stacker. @@ -108,6 +118,9 @@ class BaseRawDataHandler extends BaseHubHandler implements HubInterface { self::PACKAGE_RAW_DATA => $rawData, self::PACKAGE_ERROR_CODE => $this->getErrorCode() )); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: EXIT!'); } /** @@ -116,9 +129,15 @@ class BaseRawDataHandler extends BaseHubHandler implements HubInterface { * @return $isPending Whether raw data is pending */ public function isRawDataPending () { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: CALLED!'); + // Does the stacker have some entries (not empty)? $isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_RAW_DATA)); + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: isPending=%d - EXIT!', intval($isPending))); + // Return it return $isPending; } @@ -145,12 +164,18 @@ class BaseRawDataHandler extends BaseHubHandler implements HubInterface { * @todo This method will be moved to a better place */ protected function ifRecipientMatchesOwnUniversalNodeLocator (array $packageData) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: packageData()=%d - CALLED!', strlen($packageData))); + // Construct own address first $ownAddress = NodeObjectFactory::createNodeInstance()->determineUniversalNodeLocator(); // Does it match? $matches = ($ownAddress === $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]); + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: matches=%d - EXIT!', intval($matches))); + // Return result return $matches; } diff --git a/application/hub/classes/handler/raw_data/socket/class_SocketRawDataHandler.php b/application/hub/classes/handler/raw_data/socket/class_SocketRawDataHandler.php index e02f2f10f..17905bfe1 100644 --- a/application/hub/classes/handler/raw_data/socket/class_SocketRawDataHandler.php +++ b/application/hub/classes/handler/raw_data/socket/class_SocketRawDataHandler.php @@ -56,16 +56,14 @@ class SocketRawDataHandler extends BaseRawDataHandler implements Networkable { } /** - * Processes raw data from given resource. This is mostly useful for TCP - * package handling and is implemented in the ???Listener class + * Processes raw data from given socket instance. This is mostly useful for + * raw package handling and is implemented in the ???Listener class. * * @param $resource A valid socket resource array * @return void */ - public function processRawDataFromResource (array $socketArray) { + public function processRawDataFromSocketArray (array $socketArray) { $this->partialStub('socketArray=' . print_r($socketArray, TRUE)); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php b/application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php index a758a1e74..b22a8d553 100644 --- a/application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php +++ b/application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php @@ -3,10 +3,17 @@ namespace Hub\Handler\Network\RawData\Tcp; // Import application-specific stuff +use Hub\Container\Socket\StorableSocket; use Hub\Handler\Network\RawData\BaseRawDataHandler; use Hub\Network\Networkable; use Hub\Pool\Poolable; +// Import framework stuff +use CoreFramework\Socket\InvalidSocketException; + +// Import SPL stuff +use \InvalidArgumentException; + /** * A TCP raw data handler * @@ -57,50 +64,56 @@ class TcpRawDataHandler extends BaseRawDataHandler implements Networkable { } /** - * Processes raw data from given resource. This is mostly useful for TCP - * package handling and is implemented in the TcpListener class + * Processes raw data from given socket instance. This is mostly useful for + * TCP package handling and is implemented in the TcpListener class. * * @param $resource A valid socket resource array * @return void + * @throws InvalidArgumentException If the socket instance is not set */ - public function processRawDataFromResource (array $socketArray) { + public function processRawDataFromSocketArray (array $socketArray) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TCP-RAWDATA-HANDLER: socketArray()=%d - CALLED!', count($socketArray))); + // Check the resource - if ((!isset($socketArray[Poolable::SOCKET_ARRAY_INSTANCE])) || (!is_resource($socketArray[Poolable::SOCKET_ARRAY_INSTANCE]))) { + if ((!isset($socketArray[Poolable::SOCKET_ARRAY_INSTANCE])) || (!($socketArray[Poolable::SOCKET_ARRAY_INSTANCE] instanceof StorableSocket))) { // Throw an exception - throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); + throw new InvalidArgumentException(sprintf('socketArray[%s] is not set or invalid.', Poolable::SOCKET_ARRAY_INSTANCE)); } // END - if // Reset error code to unhandled $this->setErrorCode(self::SOCKET_ERROR_UNHANDLED); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-HANDLER: Handling TCP package from resource=' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE] . ',type=' . $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE] . ',last error=' . socket_strerror($this->lastSocketError)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-RAWDATA-HANDLER: Handling TCP package from resource=' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE] . ',type=' . $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE] . ',last error=' . socket_strerror($this->lastSocketError)); + $this->partialStub('Please rewrite this part.'); + return; /* * Read the raw data from socket. If you change PHP_BINARY_READ to * PHP_NORMAL_READ, this line will endless block. This script does only - * provide simultanous threads, not real. + * provide simultanous or faked threads, not real. */ $rawData = socket_read($socketArray[Poolable::SOCKET_ARRAY_INSTANCE], $this->getConfigInstance()->getConfigEntry('tcp_buffer_length'), PHP_BINARY_READ); // Get socket error code back - $this->lastSocketError = socket_last_error($socketArray[Poolable::SOCKET_ARRAY_INSTANCE]); + $this->lastSocketError = $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketLastErrorCode(); // Debug output of read data length - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-HANDLER: rawData[' . gettype($rawData) . ']=' . strlen($rawData) . ',MD5=' . md5($rawData) . ',resource=' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE] . ',error=' . socket_strerror($this->lastSocketError)); - /* NOISY-DEBUG: */ if ($rawData !== FALSE) self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-HANDLER: rawData=' . $rawData); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-RAWDATA-HANDLER: rawData[' . gettype($rawData) . ']=' . strlen($rawData) . ',MD5=' . md5($rawData) . ',resource=' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE] . ',this->lastSocketError=' . socket_strerror($this->lastSocketError)); + /* NOISY-DEBUG: */ if ($rawData !== FALSE) self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-RAWDATA-HANDLER: rawData=' . $rawData); // Is it valid? if ($this->lastSocketError == 11) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-HANDLER: Ignoring error 11 (Resource temporary unavailable) from socket resource=' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-RAWDATA-HANDLER: Ignoring error 11 (Resource temporary unavailable) from socket resource=' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]); /* * Error code 11 (Resource temporary unavailable) can be safely * ignored on non-blocking sockets. The socket is currently not * sending any data. */ - socket_clear_error($socketArray[Poolable::SOCKET_ARRAY_INSTANCE]); + $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->clearLastSocketError(); // Skip any further processing return; @@ -108,6 +121,9 @@ class TcpRawDataHandler extends BaseRawDataHandler implements Networkable { // Network error or connection lost $this->setErrorCode($this->lastSocketError); } elseif (empty($rawData)) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-RAWDATA-HANDLER: No raw data pending. - EXIT!'); + // The peer did send nothing to us which is now being ignored return; } else { @@ -117,9 +133,13 @@ class TcpRawDataHandler extends BaseRawDataHandler implements Networkable { * well-formed BASE64-encoded message with start and markers. This * will be checked later on. */ - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-HANDLER: Adding ' . strlen($rawData) . ' bytes to stacker ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-RAWDATA-HANDLER: Adding ' . strlen($rawData) . ' bytes to stacker ...'); $this->addRawDataToStacker($rawData); } + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-RAWDATA-HANDLER: EXIT!'); + } } diff --git a/application/hub/classes/handler/raw_data/udp/class_UdpRawDataHandler.php b/application/hub/classes/handler/raw_data/udp/class_UdpRawDataHandler.php index f1aaa667f..a8e193b07 100644 --- a/application/hub/classes/handler/raw_data/udp/class_UdpRawDataHandler.php +++ b/application/hub/classes/handler/raw_data/udp/class_UdpRawDataHandler.php @@ -57,25 +57,30 @@ class UdpRawDataHandler extends BaseRawDataHandler implements Networkable { } /** - * Processes raw data from given resource. This is mostly useful for UDP - * package handling and is implemented in the UdpListener class + * Processes raw data from given socket instance. This is mostly useful for + * UDP package handling and is implemented in the UDPListener class * - * @param $socketArray A valid socket resource array + * @param $resource A valid socket resource array * @return void - * @throws InvalidResourceException If the given resource is invalid - * @todo 0% + * @throws InvalidArgumentException If the socket instance is not set */ - public function processRawDataFromResource (array $socketArray) { + public function processRawDataFromSocketArray (array $socketArray) { + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UDP-HANDLER: socketArray()=%d - CALLED!', count($socketArray))); + // Check the resource - if ((!isset($socketArray[Poolable::SOCKET_ARRAY_INSTANCE])) || (!is_resource($socketArray[Poolable::SOCKET_ARRAY_INSTANCE]))) { + if ((!isset($socketArray[Poolable::SOCKET_ARRAY_INSTANCE])) || (!($socketArray[Poolable::SOCKET_ARRAY_INSTANCE] instanceof StorableSocket))) { // Throw an exception - throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); + throw new InvalidArgumentException(sprintf('socketArray[%s] is not set or invalid.', Poolable::SOCKET_ARRAY_INSTANCE)); } // END - if - // Implement processing here - $this->partialStub('Please implement this method. resource=' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE] . ',type=' . $socketArray[Poolable::SOCKET_ARRRAY_CONN_TYPE]); + // Reset error code to unhandled + $this->setErrorCode(self::SOCKET_ERROR_UNHANDLED); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UDP-HANDLER: Handling UDP package from resource=' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE] . ',type=' . $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE] . ',last error=' . socket_strerror($this->lastSocketError)); + $this->partialStub('Please rewrite this part.'); + return; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/listener/class_BaseListener.php b/application/hub/classes/listener/class_BaseListener.php index 90fe089b3..a557a59cc 100644 --- a/application/hub/classes/listener/class_BaseListener.php +++ b/application/hub/classes/listener/class_BaseListener.php @@ -5,9 +5,11 @@ namespace Hub\Listener; // Import application-specific stuff use Hub\Container\Socket\StorableSocket; use Hub\Factory\Information\Connection\ConnectionInfoFactory; +use Hub\Factory\Network\Locator\UniversalNodeLocatorFactory; use Hub\Factory\Node\NodeObjectFactory; use Hub\Factory\Socket\SocketFactory; use Hub\Generic\BaseHubSystem; +use Hub\Information\ShareableInfo; use Hub\Network\Package\NetworkPackage; use Hub\Pool\Peer\PoolablePeer; use Hub\Pool\Poolable; @@ -17,9 +19,13 @@ use CoreFramework\Factory\ObjectFactory; use CoreFramework\Factory\Registry\Socket\SocketRegistryFactory; use CoreFramework\Generic\UnsupportedOperationException; use CoreFramework\Socket\InvalidServerSocketException; +use CoreFramework\Socket\SocketAlreadyRegisteredException; use CoreFramework\Visitor\Visitable; use CoreFramework\Visitor\Visitor; +// Import SPL stuff +use \LogicException; + /** * A general listener class * @@ -166,10 +172,13 @@ class BaseListener extends BaseHubSystem implements Visitable { * @throws SocketAlreadyRegisteredException If the given resource is already registered */ protected function registerServerSocketInstance (StorableSocket $socketInstance) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance=%s - CALLED!', $socketInstance->__toString())); + // First check if it is valid if ($this->isServerSocketRegistered($socketInstance)) { // Already registered - throw new SocketAlreadyRegisteredException($this, self::EXCEPTION_SOCKET_ALREADY_REGISTERED); + throw new SocketAlreadyRegisteredException(array($this, $socketInstance->getSocketResource()), self::EXCEPTION_SOCKET_ALREADY_REGISTERED); } // END - if // Get a socket registry instance (singleton) @@ -184,8 +193,14 @@ class BaseListener extends BaseHubSystem implements Visitable { // Register the socket $registryInstance->registerSocketInstance($infoInstance, $socketInstance); + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: Setting socketInstance ... (socketResource=%s)', $socketInstance->getSocketResource())); + // And set it here $this->setSocketInstance($socketInstance); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: EXIT!'); } /** @@ -193,20 +208,39 @@ class BaseListener extends BaseHubSystem implements Visitable { * * @param $socketInstance An instance of a StorableSocket class * @return $isRegistered Whether given server socket is registered + * @throws LogicException If no info instance can be created */ protected function isServerSocketRegistered (StorableSocket $socketInstance) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance=%s - CALLED!', $socketInstance->__toString())); + // Get a socket registry instance (singleton) $registryInstance = SocketRegistryFactory::createSocketRegistryInstance(); // Get a connection info instance $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($this->getProtocolName(), 'listener'); + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: infoInstance[]=%s', gettype($infoInstance))); + + // Is the instance set? + if (!($infoInstance instanceof ShareableInfo)) { + // Should not happen + throw new LogicException(sprintf('infoInstance[]=%s does not implement ShareableInfo', gettype($infoInstance))); + } // END - if + // Will the info instance with listener data $infoInstance->fillWithListenerInformation($this); + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: Checking socketInstance ... (socketResource=%s)', $socketInstance->getSocketResource())); + // Check it $isRegistered = $registryInstance->isSocketRegistered($infoInstance, $socketInstance); + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: isRegistered=%d - EXIT!', intval($isRegistered))); + // Return result return $isRegistered; } @@ -252,6 +286,9 @@ class BaseListener extends BaseHubSystem implements Visitable { * @return void */ protected function doListenSocketSelect ($peerSuffix) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: peerSuffix=%s - CALLED!', $peerSuffix)); + // Check on all instances assert($this->getPoolInstance() instanceof Poolable); assert($this->getSocketInstance()->isValidSocket()); @@ -259,12 +296,21 @@ class BaseListener extends BaseHubSystem implements Visitable { // Get next socket instance from pool over the factory $socketInstance = SocketFactory::createNextAcceptedSocketFromPool($this->getPoolInstance(), $this->getSocketInstance()); + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance[]=%s accepted.', gettype($socketInstance))); + // Is socket instance set? if (!($socketInstance instanceof StorableSocket)) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: No new connection on listener ... - EXIT!'); + // Nothing has changed on the listener return; } // END - if + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance.socketResource=%s accepted.', $socketInstance->getSocketResource())); + // Init peer address/port $peerAddress = '0.0.0.0'; $peerPort = '0'; @@ -306,15 +352,52 @@ class BaseListener extends BaseHubSystem implements Visitable { // Get the current value $currentSocketData = $this->getIteratorInstance()->current(); + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: currentSocketData=' . $currentSocketData[Poolable::SOCKET_ARRAY_INSTANCE] . ',type=' . $currentSocketData[Poolable::SOCKET_ARRAY_CONN_TYPE] . ',serverSocket=' . $this->getSocketInstance()->getSocketResource()); + // Handle it here, if not main server socket - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-LISTENER: currentSocketData=' . $currentSocketData[Poolable::SOCKET_ARRAY_INSTANCE] . ',type=' . $currentSocketData[Poolable::SOCKET_ARRAY_CONN_TYPE] . ',serverSocket=' . $this->getSocketInstance()->getSocketResource()); if (($currentSocketData[Poolable::SOCKET_ARRAY_CONN_TYPE] != StorableSocket::CONNECTION_TYPE_SERVER) && (!$currentSocketData[Poolable::SOCKET_ARRAY_INSTANCE]->equals($this->getSocketInstance()))) { // ... or else it will raise warnings like 'Transport endpoint is not connected' - $this->getHandlerInstance()->processRawDataFromResource($currentSocketData); + $this->getHandlerInstance()->processRawDataFromSocketArray($currentSocketData); } // END - if // Advance to next entry. This should be the last line. $this->getIteratorInstance()->next(); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: EXIT!'); + } + + /** + * Checks whether the listener would accept the given package data array + * + * @param $packageData Raw package data + * @return $accepts Whether this listener does accept + */ + public function ifListenerAcceptsPackageData (array $packageData) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: packageData()=%d - CALLED!', count($packageData))); + + // Check if same socket protocol + $socketProtocol = $this->getSocketInstance()->getSocketProtocol(); + + // Get UNL instance + $unlInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]); + + // Get protocol from it + $unlProtocol = $unlInstance->getUnlProtocol(); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: unlInstance.unlProtocol=%s,socketProtocol=%s', $unlProtocol, $socketProtocol)); + + // Is same protocol? + $accepts = ($unlProtocol == $socketProtocol); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: accepts=%d - EXIT!', $accepts)); + + // Return the result + return $accepts; } } diff --git a/application/hub/classes/listener/class_BaseListenerDecorator.php b/application/hub/classes/listener/class_BaseListenerDecorator.php index 63c6ec3c8..620a4eec4 100644 --- a/application/hub/classes/listener/class_BaseListenerDecorator.php +++ b/application/hub/classes/listener/class_BaseListenerDecorator.php @@ -125,6 +125,10 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable { * @return $poolInstance A peer pool instance */ public final function getPoolInstance () { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER-DECORATOR: Getting poolInstance from inner listenerInstance=%s - CALLED!', $this->getListenerInstance()->__toString())); + + // Get it return $this->getListenerInstance()->getPoolInstance(); } @@ -152,6 +156,9 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable { return; } // END - if + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER-DECORATOR: handlerInstance=%s', $handlerInstance->__toString())); + // Does the handler have some decoded data pending? if (!$handlerInstance->isRawDataPending()) { // No data is pending so skip further code silently diff --git a/application/hub/classes/listener/socket/class_SocketFileListener.php b/application/hub/classes/listener/socket/class_SocketFileListener.php index 002b09486..d35a4bc00 100644 --- a/application/hub/classes/listener/socket/class_SocketFileListener.php +++ b/application/hub/classes/listener/socket/class_SocketFileListener.php @@ -5,6 +5,7 @@ namespace Hub\Listener\Socket; // Import application-specific stuff use Hub\Container\Socket\StorableSocket; use Hub\Factory\Socket\SocketFactory; +use Hub\Factory\Tag\Package\PackageTagsFactory; use Hub\Listener\BaseListener; use Hub\Listener\Listenable; @@ -105,8 +106,14 @@ class SocketFileListener extends BaseListener implements Listenable { * @return void */ public function doListen() { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Calling this->doListenSocketSelect() ... - CALLED!'); + // Call super method $this->doListenSocketSelect(''); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: EXIT!'); } /** @@ -116,7 +123,32 @@ class SocketFileListener extends BaseListener implements Listenable { * @return $accepts Whether this listener does accept */ public function ifListenerAcceptsPackageData (array $packageData) { - $this->partialStub('Need to implement this method.'); + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FILE-LISTENER: packageData()=%d - CALLED!', count($packageData))); + + // Call parent method + if (!parent::ifListenerAcceptsPackageData($packageData)) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Protocol mismatching, not accepting package.'); + + // Is already different protocol + return FALSE; + } // END - if + + // Debugging + /* DEBUG-DIE: */ die(__METHOD__.':packageData='.print_r($packageData, TRUE)); + + // Get a tags instance + $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); + + // So is the package accepted with this listener? + $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FILE-LISTENER: accepts=%d - EXIT!', $accepts)); + + // Return the result + return $accepts; } /** diff --git a/application/hub/classes/listener/socket/decorator/class_SocketFileListenerDecorator.php b/application/hub/classes/listener/socket/decorator/class_SocketFileListenerDecorator.php index afbb779a5..cd1af3927 100644 --- a/application/hub/classes/listener/socket/decorator/class_SocketFileListenerDecorator.php +++ b/application/hub/classes/listener/socket/decorator/class_SocketFileListenerDecorator.php @@ -96,14 +96,8 @@ class SocketFileListenerDecorator extends BaseListenerDecorator implements Liste * @return $accepts Whether this listener does accept */ public function ifListenerAcceptsPackageData (array $packageData) { - // Get a tags instance - $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); - - // So is the package accepted with this listener? - $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this); - - // Return the result - return $accepts; + // Call inner method, no decoration is wanted in this method + return $this->getListenerInstance()->ifListenerAcceptsPackageData($packageData); } } diff --git a/application/hub/classes/listener/tcp/class_TcpListener.php b/application/hub/classes/listener/tcp/class_TcpListener.php index 04497715f..afe84f4d6 100644 --- a/application/hub/classes/listener/tcp/class_TcpListener.php +++ b/application/hub/classes/listener/tcp/class_TcpListener.php @@ -105,8 +105,14 @@ class TcpListener extends BaseListener implements Listenable { * @return void */ public function doListen () { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-LISTENER: Calling this->doListenSocketSelect(:0) ... - CALLED!'); + // Call super method $this->doListenSocketSelect(':0'); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-LISTENER: EXIT!'); } /** diff --git a/application/hub/classes/listener/tcp/decorators/class_ClientTcpListenerDecorator.php b/application/hub/classes/listener/tcp/decorators/class_ClientTcpListenerDecorator.php index 7f387d6ee..672c1384b 100644 --- a/application/hub/classes/listener/tcp/decorators/class_ClientTcpListenerDecorator.php +++ b/application/hub/classes/listener/tcp/decorators/class_ClientTcpListenerDecorator.php @@ -96,16 +96,32 @@ class ClientTcpListenerDecorator extends BaseListenerDecorator implements Listen * @return $accepts Whether this listener does accept */ public function ifListenerAcceptsPackageData (array $packageData) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CLIENT-TCP-LISTENER: packageData()=%d - CALLED!', count($packageData))); + + // Call parent method + if (!parent::ifListenerAcceptsPackageData($packageData)) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Protocol mismatching, not accepting package.'); + + // Is already different protocol + return FALSE; + } // END - if + + // Debugging + /* DEBUG-DIE: */ die(__METHOD__.':packageData='.print_r($packageData, TRUE)); + // Get a tags instance $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); // So is the package accepted with this listener? $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this); + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CLIENT-TCP-LISTENER: accepts=%d - EXIT!', $accepts)); + // Return the result return $accepts; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/listener/tcp/decorators/class_HubTcpListenerDecorator.php b/application/hub/classes/listener/tcp/decorators/class_HubTcpListenerDecorator.php index e25230176..b4e252b19 100644 --- a/application/hub/classes/listener/tcp/decorators/class_HubTcpListenerDecorator.php +++ b/application/hub/classes/listener/tcp/decorators/class_HubTcpListenerDecorator.php @@ -96,16 +96,32 @@ class HubTcpListenerDecorator extends BaseListenerDecorator implements Listenabl * @return $accepts Whether this listener does accept */ public function ifListenerAcceptsPackageData (array $packageData) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TCP-LISTENER: packageData()=%d - CALLED!', count($packageData))); + + // Call parent method + if (!parent::ifListenerAcceptsPackageData($packageData)) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Protocol mismatching, not accepting package.'); + + // Is already different protocol + return FALSE; + } // END - if + + // Debugging + /* DEBUG-DIE: */ die(__METHOD__.':packageData='.print_r($packageData, TRUE)); + // Get a tags instance $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); // So is the package accepted with this listener? $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this); + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TCP-LISTENER: accepts=%d - EXIT!', $accepts)); + // Return the result return $accepts; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/listener/udp/class_UdpListener.php b/application/hub/classes/listener/udp/class_UdpListener.php index 5c9dc4aaa..60a94ecac 100644 --- a/application/hub/classes/listener/udp/class_UdpListener.php +++ b/application/hub/classes/listener/udp/class_UdpListener.php @@ -10,6 +10,7 @@ use Hub\Listener\Listenable; // Import framework stuff use CoreFramework\Factory\ObjectFactory; +use CoreFramework\Generic\UnsupportedOperationException; /** * An UDP connection listener @@ -66,12 +67,28 @@ class UdpListener extends BaseListener implements Listenable { * @return void */ public function initListener () { - // Get socket instance + // Get instance from socket factory $socketInstance = SocketFactory::createListenUdpSocket($this); - // Remember the socket in our class + // Set socket instance $this->registerServerSocketInstance($socketInstance); + // Initialize the peer pool instance + $poolInstance = ObjectFactory::createObjectByConfiguredName('node_pool_class', array($this)); + + // Add main socket + $poolInstance->addPeer($socketInstance, StorableSocket::CONNECTION_TYPE_SERVER); + + // And add it to this listener + $this->setPoolInstance($poolInstance); + + // Initialize iterator for listening on packages + $iteratorInstance = $poolInstance->createListIteratorInstance('network_listen'); + + // Rewind it and remember it in this class + $iteratorInstance->rewind(); + $this->setIteratorInstance($iteratorInstance); + // Initialize the network package handler $handlerInstance = ObjectFactory::createObjectByConfiguredName('udp_raw_data_handler_class'); @@ -86,43 +103,16 @@ class UdpListener extends BaseListener implements Listenable { * "Listens" for incoming network packages * * @return void - * @todo ~50% done */ - public function doListen() { - $this->partialStub('Please rewrite this part.'); - return; - - // Read a package and determine the peer - $amount = @socket_recvfrom($this->getSocketInstance(), $rawData, $this->getConfigInstance()->getConfigEntry('udp_buffer_length'), MSG_DONTWAIT, $peer, $port); - - // Get last error - $lastError = $this->getSocketInstance()->getSocketLastErrorCode(); - - // Do we have an error at the line? - if ($lastError == 11) { - /* - * This (resource temporary unavailable) can be safely ignored on - * "listening" UDP ports. If we don't clear the error here, our UDP - * "listener" won't read any packages except if the UDP sender - * starts the transmission before this "listener" came up... - */ - $this->getSocketInstance()->clearLastSocketError(); - - // Skip further processing - return; - } elseif ($lastError > 0) { - // Other error detected - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UDP-LISTENER: Error detected: ' . socket_strerror($lastError)); - - // Skip further processing - return; - } elseif ((empty($rawData)) || (trim($peer) == '')) { - // Zero sized packages/peer names are usual in non-blocking mode - return; - } // END - if - - // Debug only - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UDP-LISTENER: Handling UDP package with size ' . strlen($rawData) . ' from peer ' . $peer . ':' . $port); + public function doListen () { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UDP-LISTENER: Calling this->doListenSocketSelect(:0) ... - CALLED!'); + + // Call super method + $this->doListenSocketSelect(':0'); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UDP-LISTENER: EXIT!'); } /** @@ -130,11 +120,10 @@ class UdpListener extends BaseListener implements Listenable { * * @param $packageData Raw package data * @return $accepts Whether this listener does accept + * @throws UnsupportedOperationException If this method is called */ - function ifListenerAcceptsPackageData (array $packageData) { - $this->partialStub('This call should not happen. Please report it.'); + public function ifListenerAcceptsPackageData (array $packageData) { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/listener/udp/decorators/class_ClientUdpListenerDecorator.php b/application/hub/classes/listener/udp/decorators/class_ClientUdpListenerDecorator.php index 2737c57a8..07804f42b 100644 --- a/application/hub/classes/listener/udp/decorators/class_ClientUdpListenerDecorator.php +++ b/application/hub/classes/listener/udp/decorators/class_ClientUdpListenerDecorator.php @@ -96,16 +96,32 @@ class ClientUdpListenerDecorator extends BaseListenerDecorator implements Listen * @return $accepts Whether this listener does accept */ function ifListenerAcceptsPackageData (array $packageData) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CLIENT-UDP-LISTENER: packageData()=%d - CALLED!', count($packageData))); + + // Call parent method + if (!parent::ifListenerAcceptsPackageData($packageData)) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Protocol mismatching, not accepting package.'); + + // Is already different protocol + return FALSE; + } // END - if + + // Debugging + /* DEBUG-DIE: */ die(__METHOD__.':packageData='.print_r($packageData, TRUE)); + // Get a tags instance $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); // So is the package accepted with this listener? $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this); + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CLIENT-UDP-LISTENER: accepts=%d - EXIT!', $accepts)); + // Return the result return $accepts; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/listener/udp/decorators/class_HubUdpListenerDecorator.php b/application/hub/classes/listener/udp/decorators/class_HubUdpListenerDecorator.php index eaaa9d0e2..1c3389fe0 100644 --- a/application/hub/classes/listener/udp/decorators/class_HubUdpListenerDecorator.php +++ b/application/hub/classes/listener/udp/decorators/class_HubUdpListenerDecorator.php @@ -96,16 +96,32 @@ class HubUdpListenerDecorator extends BaseListenerDecorator implements Listenabl * @return $accepts Whether this listener does accept */ public function ifListenerAcceptsPackageData (array $packageData) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-UDP-LISTENER: packageData()=%d - CALLED!', count($packageData))); + + // Call parent method + if (!parent::ifListenerAcceptsPackageData($packageData)) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Protocol mismatching, not accepting package.'); + + // Is already different protocol + return FALSE; + } // END - if + + // Debugging + /* DEBUG-DIE: */ die(__METHOD__.':packageData='.print_r($packageData, TRUE)); + // Get a tags instance $tagsInstance = PackageTagsFactory::createPackageTagsInstance(); // So is the package accepted with this listener? $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this); + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-UDP-LISTENER: accepts=%d - EXIT!', $accepts)); + // Return the result return $accepts; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/package/class_NetworkPackage.php b/application/hub/classes/package/class_NetworkPackage.php index 80ef74715..2ffd30771 100644 --- a/application/hub/classes/package/class_NetworkPackage.php +++ b/application/hub/classes/package/class_NetworkPackage.php @@ -1077,6 +1077,9 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R * @return $isPending Whether decoded raw data is pending */ private function isRawDataPending () { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!'); + // Just return whether the stack is not empty $isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECODED_INCOMING)); @@ -1090,12 +1093,18 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R * @return $hasArrived Whether new raw package data has arrived for processing */ public function isNewRawDataPending () { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: Calling this->getListenerPoolInstance()->accept(%s) ... - CALLED!', $this->getVisitorInstance())); + // Visit the pool. This monitors the pool for incoming raw data. $this->getListenerPoolInstance()->accept($this->getVisitorInstance()); // Check for new data arrival $hasArrived = $this->isRawDataPending(); + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: hasArrived=%d - EXIT!', intval($hasArrived))); + // Return the status return $hasArrived; } diff --git a/application/hub/classes/pools/class_BasePool.php b/application/hub/classes/pools/class_BasePool.php index 935a0e62d..ab2ba2ed4 100644 --- a/application/hub/classes/pools/class_BasePool.php +++ b/application/hub/classes/pools/class_BasePool.php @@ -52,6 +52,9 @@ abstract class BasePool extends BaseHubSystem implements Poolable, Visitable { // Init the pool entries $this->poolEntriesInstance = ObjectFactory::createObjectByConfiguredName('pool_entries_list_class'); + + // Register this instance as call-back + $this->getPoolEntriesInstance()->setCallbackInstance($this); } /** @@ -199,4 +202,36 @@ abstract class BasePool extends BaseHubSystem implements Poolable, Visitable { return $iteratorInstance; } + /** + * Creates a hash based on given entry + * + * @param $entry Array entry to be used + * @return $hash Hash from it + */ + public function generateListHashFromEntry (array $entry) { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: entry()=%d - CALLED!', count($entry))); + + // Debugging: + //* DEBUG-DIE: */ die(__METHOD__.':entry='.print_r($entry, TRUE)); + + // Init variable + $hash = NULL; + + // Is 'instance' and 'connection_type' set? + if ((isset($entry[Poolable::SOCKET_ARRAY_INSTANCE])) && (isset($entry[Poolable::SOCKET_ARRAY_CONN_TYPE]))) { + // Get socket resource and type + $hash = $entry[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource() . ':' . $entry[Poolable::SOCKET_ARRAY_CONN_TYPE]; + } else { + // Not supported + $this->debugInstance(sprintf('[%s:%d]: entry=%s is not supported.', __METHOD__, __LINE__, print_r($entry, TRUE))); + } + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: hash[%s]=%s - EXIT!', gettype($hash), $hash)); + + // Return hash + return $hash; + } + } diff --git a/application/hub/classes/pools/peer/class_DefaultPeerPool.php b/application/hub/classes/pools/peer/class_DefaultPeerPool.php index 0ab4cee09..a843c7c9d 100644 --- a/application/hub/classes/pools/peer/class_DefaultPeerPool.php +++ b/application/hub/classes/pools/peer/class_DefaultPeerPool.php @@ -133,11 +133,11 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { } // END - if } else { // Server sockets won't work with socket_getpeername() - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Socket resource is server socket (' . $socketInstance->getSocketResource() . '). This is not a bug.'); + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: Socket resource is server socket (' . $socketInstance->getSocketResource() . '). This is not a bug.'); } // Debug message - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Adding peer ' . $peerAddress . ':' . $peerPort . ',socketResource=' . $socketInstance->getSocketResource() . ',connectionType=' . $connectionType); + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: Adding peer ' . $peerAddress . ':' . $peerPort . ',socketResource=' . $socketInstance->getSocketResource() . ',connectionType=' . $connectionType); // Construct the array $socketArray = array( @@ -228,7 +228,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { */ public function getSocketFromPackageData (array $packageData, $connectionType = NULL) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL:packageData()=%d,connectionType[%s]=%s - CALLED!', count($packageData), gettype($connectionType), $connectionType)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL:packageData()=%d,connectionType[%s]=%s - CALLED!', count($packageData), gettype($connectionType), $connectionType)); // Default is no socket $socketInstance = NULL; @@ -240,7 +240,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { $unlInstance = $handlerInstance->getUniversalNodeLocatorInstance(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Checking ' . count($this->getAllSockets()) . ' socket(s),unlInstance.unl=' . $unlInstance->generateUnl() . ' ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: Checking ' . count($this->getAllSockets()) . ' socket(s),unlInstance.unl=' . $unlInstance->generateUnl() . ' ...'); // Default is all sockets $sockets = $this->getAllSockets(); @@ -248,7 +248,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { // Get all sockets and check them, skip the server socket foreach ($sockets as $socketArray) { // Debugging: - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: socketArray(%d)=%s', count($socketArray), implode(',', $socketArray))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: socketArray(%d)=%s', count($socketArray), implode(',', $socketArray))); //* DEBUG-DIE: */ die(__METHOD__.':connectionType='.$connectionType.',socketArray='.print_r($socketArray, TRUE)); // Is connection type set? @@ -263,12 +263,12 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE); } elseif ((!empty($connectionType)) && ($socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE] !== $connectionType)) { // Skip unwanted sockets - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: Skipping unwanted socket %s of type %s/%s ...', $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE], $connectionType)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: Skipping unwanted socket %s of type %s/%s ...', $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE], $connectionType)); continue; } // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: socketInstance.socketResource=%s,socketInstance.socketProtocol=%s,socketArray[%s]=%s', $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketProtocol(), Poolable::SOCKET_ARRAY_CONN_TYPE, $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE])); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: socketInstance.socketResource=%s,socketInstance.socketProtocol=%s,socketArray[%s]=%s', $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketProtocol(), Poolable::SOCKET_ARRAY_CONN_TYPE, $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE])); // Init peer address/port $peerAddress = '0.0.0.0'; @@ -281,7 +281,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { } // END - if // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: peerAddress=%s,peerPort=%d,unlInstance.addressPart=%s', $peerAddress, $peerPort, $unlInstance->getAddressPart())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: peerAddress=%s,peerPort=%d,unlInstance.addressPart=%s', $peerAddress, $peerPort, $unlInstance->getAddressPart())); // If the "peer" IP and recipient is same, use it if ($peerAddress == $unlInstance->getAddressPart()) { @@ -289,13 +289,15 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { $socketInstance = $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]; // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: peerAddress=%s matches with recipient IP address. Taking socketResource=%s,type=%s', $peerAddress, $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE])); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: peerAddress=%s matches with recipient IP address. Taking socketResource=%s,type=%s', $peerAddress, $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE])); break; } // END - if } // END - foreach + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: socketInstance[]=' . gettype($socketInstance) . ' - EXIT!'); + // Return the determined socket instance - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: socketInstance[]=' . gettype($socketInstance)); return $socketInstance; } diff --git a/application/hub/classes/registry/socket/class_SocketRegistry.php b/application/hub/classes/registry/socket/class_SocketRegistry.php index 46ef6cfaf..dcc614694 100644 --- a/application/hub/classes/registry/socket/class_SocketRegistry.php +++ b/application/hub/classes/registry/socket/class_SocketRegistry.php @@ -17,6 +17,7 @@ use CoreFramework\Factory\ObjectFactory; use CoreFramework\Registry\BaseRegistry; use CoreFramework\Registry\Register; use CoreFramework\Registry\Sub\SubRegistry; +use CoreFramework\Socket\SocketAlreadyRegisteredException; /** * A Socket registry @@ -222,7 +223,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke // Is the socket already registered? if ($this->isSocketRegistered($infoInstance, $socketInstance)) { // Throw the exception - throw new SocketAlreadyRegisteredException(array($infoInstance, $socketInstance), BaseListener::EXCEPTION_SOCKET_ALREADY_REGISTERED); + throw new SocketAlreadyRegisteredException(array($infoInstance, $socketInstance->getSocketResource()), BaseListener::EXCEPTION_SOCKET_ALREADY_REGISTERED); } // END - if // Does the instance exist? diff --git a/application/hub/classes/tasks/network/class_NetworkPackageReaderTask.php b/application/hub/classes/tasks/network/class_NetworkPackageReaderTask.php index 9073efe36..09b1a4895 100644 --- a/application/hub/classes/tasks/network/class_NetworkPackageReaderTask.php +++ b/application/hub/classes/tasks/network/class_NetworkPackageReaderTask.php @@ -87,6 +87,9 @@ class NetworkPackageReaderTask extends BaseTask implements Taskable, Visitable { // Get package instance $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-READER-TASK: packageInstance=%s', $packageInstance->__toString())); + // Do we have something to handle? if ($packageInstance->isProcessedMessagePending()) { // Trace message diff --git a/application/hub/classes/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php b/application/hub/classes/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php index 38c50eb18..6f7e64d9c 100644 --- a/application/hub/classes/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php +++ b/application/hub/classes/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php @@ -100,7 +100,7 @@ class RawDataPoolMonitorVisitor extends BaseVisitor implements PoolVisitor, List // Do monitor here /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: Visiting decoratorInstance=' . $decoratorInstance->__toString() . ' - CALLED!'); $decoratorInstance->monitorIncomingRawData(); - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: Visiting decoratorInstance=' . $decoratorInstance->__toString() . ' - FINISH'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: Visiting decoratorInstance=' . $decoratorInstance->__toString() . ' - EXIT!'); } } diff --git a/application/hub/classes/visitor/tasks/class_ActiveTaskVisitor.php b/application/hub/classes/visitor/tasks/class_ActiveTaskVisitor.php index d615b6944..634c1ed83 100644 --- a/application/hub/classes/visitor/tasks/class_ActiveTaskVisitor.php +++ b/application/hub/classes/visitor/tasks/class_ActiveTaskVisitor.php @@ -101,7 +101,7 @@ class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, PoolVisitor, // Do "listen" here /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!'); $listenerInstance->doListen(); - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting listenerInstance=' . $listenerInstance->__toString() . ' - FINISH'); + /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting listenerInstance=' . $listenerInstance->__toString() . ' - EXIT!'); } /** diff --git a/application/hub/exceptions/socket/class_NoSocketRegisteredException.php b/application/hub/exceptions/socket/class_NoSocketRegisteredException.php index cbce9f062..0bcb39a41 100644 --- a/application/hub/exceptions/socket/class_NoSocketRegisteredException.php +++ b/application/hub/exceptions/socket/class_NoSocketRegisteredException.php @@ -5,6 +5,9 @@ namespace Hub\Socket; // Inport application-specific stuff use Hub\Handler\Protocol\HandleableProtocol; +// Import framework stuff +use CoreFramework\Socket\AbstractSocketException; + /** * This exception is thrown when the requested socket is not thrown * diff --git a/application/hub/exceptions/socket/class_SocketShutdownException.php b/application/hub/exceptions/socket/class_SocketShutdownException.php index a826fa2a4..f79d103f6 100644 --- a/application/hub/exceptions/socket/class_SocketShutdownException.php +++ b/application/hub/exceptions/socket/class_SocketShutdownException.php @@ -5,6 +5,9 @@ namespace Hub\Socket; // Import application-specific stuff use Hub\Helper\Connection\ConnectionHelper; +// Import framework stuff +use CoreFramework\Socket\AbstractSocketException; + /** * This exception is thrown if the socket cannot be shut down is not error 107 * which is "Transport endpoint not connected". diff --git a/application/hub/interfaces/handler/network/class_Networkable.php b/application/hub/interfaces/handler/network/class_Networkable.php index 4cd6ed37c..a490a9778 100644 --- a/application/hub/interfaces/handler/network/class_Networkable.php +++ b/application/hub/interfaces/handler/network/class_Networkable.php @@ -32,14 +32,14 @@ use CoreFramework\Handler\DataSet\HandleableDataSet; */ interface Networkable extends HandleableDataSet, HubInterface { /** - * Processes raw data from given resource. This is mostly useful for TCP - * package handling and is implemented in the TcpListener class + * Processes raw data from given socket instance. This is mostly useful for + * package handling and is implemented in the TcpListener class. * * @param $socketData A valid socket resource array * @return void * @throws InvalidResourceException If the given resource is invalid */ - function processRawDataFromResource (array $socketData); + function processRawDataFromSocketArray (array $socketData); /** * Checks whether decoded data is pending for further processing. diff --git a/core b/core index 0a6b81dde..fc0b718d5 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 0a6b81dde16619b6d4466cca1ff8ad52226e9384 +Subproject commit fc0b718d5c258e187b226e2a088769e5d14fcc1f -- 2.39.5