From 60c9cd34c97d52e929b18d4026ec6e9f43e86606 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 26 Oct 2020 05:16:26 +0100 Subject: [PATCH] Continued: - $this and $this->getSocketResource() can be reduced to $this only and let the exception's code invoke the getter method. - Removed deprecated $socketData array, this info is now fully stored in $this already MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../socket/class_SocketContainer.php | 106 ++++++++---------- .../factories/socket/class_SocketFactory.php | 40 +++---- .../package/class_NetworkPackageHandler.php | 2 +- .../ipv4/tcp/class_TcpConnectionHelper.php | 2 +- .../classes/listener/class_BaseListener.php | 2 +- .../pools/peer/class_DefaultPeerPool.php | 6 +- .../container/socket/class_StorableSocket.php | 7 +- 7 files changed, 74 insertions(+), 91 deletions(-) diff --git a/application/hub/classes/container/socket/class_SocketContainer.php b/application/hub/classes/container/socket/class_SocketContainer.php index dd7cb5c08..8e664a304 100644 --- a/application/hub/classes/container/socket/class_SocketContainer.php +++ b/application/hub/classes/container/socket/class_SocketContainer.php @@ -290,7 +290,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita // Should be valid socket if (!$this->isValidSocket()) { // Throw exception - throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this), self::EXCEPTION_INVALID_SOCKET); } // END - if // Init result @@ -340,7 +340,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita // Should be valid socket if (!$this->isValidSocket()) { // Throw exception - throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this), self::EXCEPTION_INVALID_SOCKET); } // END - if // Get package data @@ -366,7 +366,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita // Should be valid socket if (!$this->isValidSocket()) { // Throw exception - throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this), self::EXCEPTION_INVALID_SOCKET); } // END - if // Get recipient @@ -398,7 +398,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita // Should be valid socket if (!$this->isValidSocket()) { // Throw exception - throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this), self::EXCEPTION_INVALID_SOCKET); } // END - if // Get recipient @@ -454,7 +454,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita // Should be valid socket if (!$this->isValidSocket()) { // Throw exception - throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this), self::EXCEPTION_INVALID_SOCKET); } // END - if // Get it from stored socket resource @@ -483,7 +483,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita // Should be valid socket if (!$this->isValidSocket()) { // Throw exception - throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this), self::EXCEPTION_INVALID_SOCKET); } // END - if // Get it from stored socket resource @@ -545,7 +545,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); if (!$this->isValidSocket()) { // Throw exception - throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this), self::EXCEPTION_INVALID_SOCKET); } elseif (is_null($this->getListenerInstance())) { // Required listener not set throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); @@ -577,7 +577,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita // Should be valid socket if (!$this->isValidSocket()) { // Throw exception - throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this), self::EXCEPTION_INVALID_SOCKET); } // END - if // Try to listen on socket @@ -603,7 +603,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita // Should be valid socket if (!$this->isValidSocket()) { // Throw exception - throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this), self::EXCEPTION_INVALID_SOCKET); } // END - if // Try to set non-blocking I/O @@ -629,7 +629,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita // Should be valid socket if (!$this->isValidSocket()) { // Throw exception - throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this), self::EXCEPTION_INVALID_SOCKET); } // END - if // Tries to set option @@ -655,7 +655,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita // Should be valid socket if (!$this->isValidSocket()) { // Throw exception - throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this), self::EXCEPTION_INVALID_SOCKET); } // END - if // Get recipient UNL @@ -765,7 +765,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita // Should be valid socket if (!$this->isValidSocket()) { // Throw exception - throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this), self::EXCEPTION_INVALID_SOCKET); } // END - if // Debug message @@ -841,7 +841,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita // Should be valid socket if (!$this->isValidSocket()) { // Throw exception - throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this), self::EXCEPTION_INVALID_SOCKET); } // END - if // Debug message @@ -949,7 +949,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita // Should be valid socket if (!$this->isValidSocket()) { // Throw exception - throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this), self::EXCEPTION_INVALID_SOCKET); } elseif ($this->getLastSocketErrorCode() === 0) { // Nothing to clear throw new BadMethodCallException(sprintf('Socket "%s" has no error reported, but method is called.', $this->getSocketResource())); @@ -1021,7 +1021,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita // Should be valid socket if (!$this->isValidSocket()) { // Throw exception - throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this), self::EXCEPTION_INVALID_SOCKET); } elseif (!isset($socketBuffer[NetworkPackageHandler::RAW_INDEX_DIFF])) { // Opps, should not happen throw new InvalidArgumentException(sprintf('socketBuffer[%s] is not set.', NetworkPackageHandler::RAW_INDEX_DIFF)); @@ -1106,40 +1106,34 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita * * @param $method Value of __METHOD__ from calling method * @param $line Value of __LINE__ from calling method - * @param $socketData A valid socket data array (0 = IP/file name, 1 = port) * @return void * @throws InvalidSocketException If the stored socket resource is no socket resource * @throws NoSocketErrorDetectedException If socket_last_error() gives zero back */ - public function handleSocketError ($method, $line, array $socketData) { + public function handleSocketError ($method, $line) { // Trace message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-SYSTEM: Handling socket errorCode=%d - CALLED!', $this->getLastSocketErrorCode())); // This method handles only socket resources if (!$this->isValidSocket()) { // No resource, abort here - throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this), self::EXCEPTION_INVALID_SOCKET); } // END - if - // Check socket array, 1st element is mostly IP address (or file name), 2nd is port number - //* DEBUG-DIE: */ die(__METHOD__ . ':socketData=' . print_r($socketData, true)); - assert(isset($socketData[0])); - assert(isset($socketData[1])); - // Get error code for first validation (0 is not an error) $errorCode = $this->getLastSocketErrorCode(); // If the error code is zero, someone called this method without an error if ($errorCode == 0) { // No error detected (or previously cleared outside this method) - throw new NoSocketErrorDetectedException(array($this, $this->getSocketResource()), BaseListener::EXCEPTION_NO_SOCKET_ERROR); + throw new NoSocketErrorDetectedException(array($this), BaseListener::EXCEPTION_NO_SOCKET_ERROR); } // END - if // Get handler (method) name $handlerName = $this->getSocketErrorHandlerFromCode($errorCode); // Call-back the error handler method - call_user_func_array(array($this, $handlerName), array($socketData)); + call_user_func_array(array($this, $handlerName)); // Finally clear the error because it has been handled $this->clearLastSocketError(); @@ -1184,13 +1178,12 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita * Handles socket error 'permission denied', but does not clear it for * later debugging purposes. * - * @param $socketData A valid socket data array (0 = IP/file name, 1 = port) * @return void * @throws SocketBindingException The socket could not be bind to */ - protected function handleSocketErrorPermissionDenied (array $socketData) { + protected function handleSocketErrorPermissionDenied () { // Trace message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Get socket error code for verification $socketError = $this->getLastSocketErrorCode(); @@ -1202,20 +1195,19 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $this->shutdownSocket(); // Throw it again - throw new SocketBindingException(array($this, $socketData, $this->getSocketResource(), $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET); + throw new SocketBindingException(array($this, $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET); } /** * Handles socket error 'connection timed out', but does not clear it for * later debugging purposes. * - * @param $socketData Valid socket data array * @return void * @throws SocketConnectionException The connection attempts fails with a time-out */ - protected function handleSocketErrorConnectionTimedOut (array $socketData) { + protected function handleSocketErrorConnectionTimedOut () { // Trace message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Get socket error code for verification $socketError = $this->getLastSocketErrorCode(); @@ -1227,20 +1219,19 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $this->shutdownSocket(); // Throw it again - throw new SocketConnectionException(array($this, $this->getSocketResource(), $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET); + throw new SocketConnectionException(array($this, $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET); } /** * Handles socket error 'resource temporary unavailable', but does not * clear it for later debugging purposes. * - * @param $socketData Valid socket data array * @return void * @throws SocketConnectionException The connection attempts fails with a time-out */ - protected function handleSocketErrorResourceUnavailable (array $socketData) { + protected function handleSocketErrorResourceUnavailable () { // Trace message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Get socket error code for verification $socketError = $this->getLastSocketErrorCode(); @@ -1252,20 +1243,19 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $this->shutdownSocket(); // Throw it again - throw new SocketConnectionException(array($this, $this->getSocketResource(), $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET); + throw new SocketConnectionException(array($this, $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET); } /** * Handles socket error 'connection refused', but does not clear it for * later debugging purposes. * - * @param $socketData Valid socket data array * @return void * @throws SocketConnectionException The connection attempts fails with a time-out */ - protected function handleSocketErrorConnectionRefused (array $socketData) { + protected function handleSocketErrorConnectionRefused () { // Trace message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Get socket error code for verification $socketError = $this->getLastSocketErrorCode(); @@ -1277,20 +1267,19 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $this->shutdownSocket(); // Throw it again - throw new SocketConnectionException(array($this, $this->getSocketResource(), $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET); + throw new SocketConnectionException(array($this, $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET); } /** * Handles socket error 'no route to host', but does not clear it for later * debugging purposes. * - * @param $socketData Valid socket data array * @return void * @throws SocketConnectionException The connection attempts fails with a time-out */ - protected function handleSocketErrorNoRouteToHost (array $socketData) { + protected function handleSocketErrorNoRouteToHost () { // Trace message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Get socket error code for verification $socketError = $this->getLastSocketErrorCode(); @@ -1302,20 +1291,18 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $this->shutdownSocket(); // Throw it again - throw new SocketConnectionException(array($this, $this->getSocketResource(), $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET); + throw new SocketConnectionException(array($this, $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET); } /** * Handles socket error 'operation already in progress' which happens in * method connectToPeerBySocketRecipient() on timed-out connection attempts. * - * @param $socketData Valid socket data array * @return void * @throws SocketConnectionException The connection attempts fails with a time-out */ - protected function handleSocketErrorOperationAlreadyProgress (array $socketData) { + protected function handleSocketErrorOperationAlreadyProgress () { // Trace message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); // Get socket error code for verification $socketError = $this->getLastSocketErrorCode(); @@ -1327,20 +1314,19 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $this->halfShutdownSocket(); // Throw it again - throw new SocketConnectionException(array($this, $this->getSocketResource(), $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET); + throw new SocketConnectionException(array($this, $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET); } /** * Handles socket error 'connection reset by peer', but does not clear it for * later debugging purposes. * - * @param $socketData Valid socket data array * @return void * @throws SocketConnectionException The connection attempts fails with a time-out */ - protected function handleSocketErrorConnectionResetByPeer (array $socketData) { + protected function handleSocketErrorConnectionResetByPeer () { // Trace message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Get socket error code for verification $socketError = $this->getLastSocketErrorCode(); @@ -1352,20 +1338,19 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $this->shutdownSocket(); // Throw it again - throw new SocketConnectionException(array($this, $this->getSocketResource(), $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET); + throw new SocketConnectionException(array($this, $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET); } /** * Handles socket error 'operation not supported', but does not clear it for * later debugging purposes. * - * @param $socketData Valid socket data array * @return void * @throws SocketOperationException The connection attempts fails with a time-out */ - protected function handleSocketErrorOperationNotSupported (array $socketData) { + protected function handleSocketErrorOperationNotSupported () { // Trace message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Get socket error code for verification $socketError = $this->getLastSocketErrorCode(); @@ -1377,19 +1362,18 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $this->shutdownSocket(); // Throw it again - throw new SocketOperationException(array($this, $this->getSocketResource(), $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET); + throw new SocketOperationException(array($this, $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET); } /** * Handles socket "error" 'operation now in progress' which can be safely * passed on with non-blocking connections. * - * @param $socketData Valid socket data array * @return void */ - protected function handleSocketErrorOperationInProgress (array $socketData) { + protected function handleSocketErrorOperationInProgress () { // Trace message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-HELPER: Operation is now in progress, this is usual for non-blocking connections and is no bug.'); } @@ -1505,7 +1489,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita // Should be valid socket if (!$this->isValidSocket()) { // Throw exception - throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this), self::EXCEPTION_INVALID_SOCKET); } // END - if // Set it diff --git a/application/hub/classes/factories/socket/class_SocketFactory.php b/application/hub/classes/factories/socket/class_SocketFactory.php index 65e00eaa9..eb0c684cb 100644 --- a/application/hub/classes/factories/socket/class_SocketFactory.php +++ b/application/hub/classes/factories/socket/class_SocketFactory.php @@ -153,7 +153,7 @@ class SocketFactory extends ObjectFactory { // Check if there was an error else if ($socketInstance->getLastSocketErrorCode() > 0) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, $packageInstance->getAllValuesAsArray()); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Is the file there? @@ -174,21 +174,21 @@ class SocketFactory extends ObjectFactory { // Try to bind to it if (!$socketInstance->bindSocketToFile()) { // Handle error here - $socketInstance->handleSocketError(__METHOD__, __LINE__, array_values($packageData)); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Start listen for connections self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Listening for connections.'); if (!$socketInstance->listenToSocket()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array_values($packageData)); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Allow non-blocking I/O self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Setting non-blocking mode.'); if (!$socketInstance->enableSocketNonBlocking()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array_values($packageData)); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Trace message @@ -240,14 +240,14 @@ class SocketFactory extends ObjectFactory { // Check if there was an error else if ($socketInstance->getLastSocketErrorCode() > 0) { // Handle this socket error with a faked recipientData array - $helperInstance->handleSocketError(__METHOD__, __LINE__, $socketInstance, array('0.0.0.0', '0')); + $helperInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Set the option to reuse the port //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Enabling re-use address ...'); if (!$socketInstance->enableSocketReuseAddress()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if /* @@ -258,7 +258,7 @@ class SocketFactory extends ObjectFactory { //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Setting non-blocking mode.'); if (!$socketInstance->enableSocketNonBlocking()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Trace message @@ -305,14 +305,14 @@ class SocketFactory extends ObjectFactory { // Check if there was an error else if ($socketInstance->getLastSocketErrorCode() > 0) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Set the option to reuse the port self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Enabling re-use address ...'); if (!$socketInstance->enableSocketReuseAddress()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if /* @@ -323,21 +323,21 @@ class SocketFactory extends ObjectFactory { self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Binding to address ' . $listenerInstance->getListenAddress() . ':' . $listenerInstance->getListenPort()); if (!$socketInstance->bindSocketToListener()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Start listen for connections self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Listening for connections.'); if (!$socketInstance->listenToSocket()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Now, we want non-blocking mode self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Setting non-blocking mode.'); if (!$socketInstance->enableSocketNonBlocking()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Trace message @@ -384,14 +384,14 @@ class SocketFactory extends ObjectFactory { // Check if there was an error else if ($socketInstance->getLastSocketErrorCode() > 0) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Set the option to reuse the port self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Enabling re-use address ...'); if (!$socketInstance->enableSocketReuseAddress()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if /* @@ -402,14 +402,14 @@ class SocketFactory extends ObjectFactory { self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Binding to address ' . $listenerInstance->getListenAddress() . ':' . $listenerInstance->getListenPort()); if (!$socketInstance->bindSocketToListener()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Now, we want non-blocking mode self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Setting non-blocking mode.'); if (!$socketInstance->enableSocketNonBlocking()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Trace message @@ -509,25 +509,25 @@ class SocketFactory extends ObjectFactory { // Try to identify socket peer if (!$socketInstance->identifySocketPeer()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Set timeout to configured seconds if (!$socketInstance->setSocketTimeoutOptions()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Enable SO_OOBINLINE if (!$socketInstance->enableSocketOutOfBandData()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Set non-blocking if (!$socketInstance->enableSocketNonBlocking()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Trace message diff --git a/application/hub/classes/handler/package/class_NetworkPackageHandler.php b/application/hub/classes/handler/package/class_NetworkPackageHandler.php index c936ad6ca..11d7334d1 100644 --- a/application/hub/classes/handler/package/class_NetworkPackageHandler.php +++ b/application/hub/classes/handler/package/class_NetworkPackageHandler.php @@ -1067,7 +1067,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei // And deliver it if (!$socketInstance->writeBufferToSocketByArray($encodedDataArray, $sentBytes)) { // Something bad happened while writing to socket - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Debug message diff --git a/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php b/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php index 334dace84..04f808f7b 100644 --- a/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php +++ b/application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php @@ -121,7 +121,7 @@ class TcpConnectionHelper extends BaseIpV4ConnectionHelper implements Connection self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TCP-CONNECTION-HELPER: helperInstance=%s,unlInstance.unlData=%s', $helperInstance->__toString(), print_r($unlInstance->getUnlData(), TRUE))); // Handle socket error - $socketInstance->handleSocketError(__METHOD__, __LINE__, $unlInstance->getUnlData()); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Okay, that should be it. Return it... diff --git a/application/hub/classes/listener/class_BaseListener.php b/application/hub/classes/listener/class_BaseListener.php index 6e428ebd4..ad696f9f8 100644 --- a/application/hub/classes/listener/class_BaseListener.php +++ b/application/hub/classes/listener/class_BaseListener.php @@ -378,7 +378,7 @@ abstract class BaseListener extends BaseHubSystem implements Visitable { // Get peer name if (!$socketInstance->getSocketPeerName($peerAddress, $peerPort)) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if // Get node instance diff --git a/application/hub/classes/pools/peer/class_DefaultPeerPool.php b/application/hub/classes/pools/peer/class_DefaultPeerPool.php index d7361ecb4..4f1ddec50 100644 --- a/application/hub/classes/pools/peer/class_DefaultPeerPool.php +++ b/application/hub/classes/pools/peer/class_DefaultPeerPool.php @@ -93,7 +93,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { // Is it without any errors? if ($errorCode > 0) { // Handle the socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if } @@ -130,7 +130,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { // Try to determine the peer's IP number if (!$socketInstance->getSocketPeerName($peerAddress, $peerPort)) { // Handle the socket error with a faked recipientData array - $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__); } // END - if } else { // Server sockets won't work with socket_getpeername() @@ -278,7 +278,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { // Try to get the "peer"'s name if (!$socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketPeerName($peerAddress, $peerPort)) { // Handle the socket error with given package data - $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->handleSocketError(__METHOD__, __LINE__, explode(':', $packageInstance->getRecipient())); + $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->handleSocketError(__METHOD__, __LINE__); } // END - if // Debug message diff --git a/application/hub/interfaces/container/socket/class_StorableSocket.php b/application/hub/interfaces/container/socket/class_StorableSocket.php index 943648258..91cf198f9 100644 --- a/application/hub/interfaces/container/socket/class_StorableSocket.php +++ b/application/hub/interfaces/container/socket/class_StorableSocket.php @@ -277,14 +277,13 @@ interface StorableSocket extends FrameworkInterface { * resource (see is_resource()) but assumes valid data in array * $recipientData, except that count($recipientData) is always 2. * - * @param $method Value of __METHOD__ from calling method - * @param $line Value of __LINE__ from calling method - * @param $socketData A valid socket data array (0 = IP/file name, 1 = port) + * @param $method Value of __METHOD__ from calling method + * @param $line Value of __LINE__ from calling method * @return void * @throws InvalidSocketException If the stored socket resource is no socket resource * @throws NoSocketErrorDetectedException If socket_last_error() gives zero back */ - function handleSocketError ($method, $line, array $socketData); + function handleSocketError ($method, $line); /** * Do the shutdown sequence for this connection helper -- 2.39.5