]> git.mxchange.org Git - hub.git/commitdiff
Surpress errors/warnings for socket_write as they flood the later logfiles, added...
authorRoland Haeder <roland@mxchange.org>
Fri, 14 Mar 2014 20:01:51 +0000 (21:01 +0100)
committerRoland Haeder <roland@mxchange.org>
Fri, 14 Mar 2014 20:01:51 +0000 (21:01 +0100)
Signed-off-by: Roland Haeder <roland@mxchange.org>
application/hub/main/handler/network/class_BaseRawDataHandler.php
application/hub/main/helper/connection/class_BaseConnectionHelper.php
application/hub/main/package/class_NetworkPackage.php

index 8fcce65fe5c569368ac872190bf2179c86ba9d07..93fdb3acf034354c7039b32fbabbe287cda62f20 100644 (file)
@@ -35,7 +35,7 @@ class BaseRawDataHandler extends BaseHandler {
        const SOCKET_ERROR_OPERATION_ALREADY_PROGRESS = 'operation_already_progress'; // 'Operation already in progress'
        const SOCKET_ERROR_RESOURCE_UNAVAILABLE       = 'resource_unavailable';       // 'Resource temporary unavailable'
        const SOCKET_ERROR_NO_ROUTE_TO_HOST           = 'no_route_to_host';           // The name says it: no route to host
-       const SOCKET_ERROR_CONNECTION_RESET_BY_PEER   = 'reset_by_peer';              // Connection reset by peer
+       const SOCKET_ERROR_CONNECTION_RESET_BY_PEER   = 'connection_reset_by_peer';   // Connection reset by peer
        const SOCKET_CONNECTED                        = 'connected';                  // Nothing errorous happens, socket is connected
 
        // - Package errors
index b58638b1adb010a810d85efe661820fa91869ed6..e5abac69ce9ef940e4370566558bf875ec5477f3 100644 (file)
@@ -584,6 +584,29 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Registerable,
                throw new SocketConnectionException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
        }
 
+       /**
+        * Handles socket error 'connection reset by peer', but does not clear it for
+        * later debugging purposes.
+        *
+        * @param       $socketResource         A valid socket resource
+        * @param       $recipientData          An array with two elements: 0=IP number, 1=port number
+        * @return      void
+        * @throws      SocketConnectionException       The connection attempts fails with a time-out
+        */
+       protected function socketErrorConnectionResetByPeerHandler ($socketResource, array $recipientData) {
+               // Get socket error code for verification
+               $socketError = socket_last_error($socketResource);
+
+               // Get error message
+               $errorMessage = socket_strerror($socketError);
+
+               // Shutdown this socket
+               $this->shutdownSocket($socketResource);
+
+               // Throw it again
+               throw new SocketConnectionException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
+       }
+
        /**
         * Handles socket "error" 'operation now in progress' which can be safely
         * passed on with non-blocking connections.
index 7e599a4166907177aaa5aec6b3f3eec741b81df2..b1b345928e33d61153e6f161d56e86fc4d4d5213 100644 (file)
@@ -836,11 +836,11 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                if ($encodedDataArray[self::RAW_DIFF_INDEX] >= 0) {
                        // Send all out (encodedData is smaller than or equal buffer size)
                        //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: MD5=' . md5(substr($encodedDataArray[self::RAW_ENCODED_DATA_INDEX], 0, ($encodedDataArray[self::RAW_BUFFER_SIZE_INDEX] - $encodedDataArray[self::RAW_DIFF_INDEX]))));
-                       $sentBytes = socket_write($encodedDataArray[self::RAW_SOCKET_INDEX], $encodedDataArray[self::RAW_ENCODED_DATA_INDEX], ($encodedDataArray[self::RAW_BUFFER_SIZE_INDEX] - $encodedDataArray[self::RAW_DIFF_INDEX]));
+                       $sentBytes = @socket_write($encodedDataArray[self::RAW_SOCKET_INDEX], $encodedDataArray[self::RAW_ENCODED_DATA_INDEX], ($encodedDataArray[self::RAW_BUFFER_SIZE_INDEX] - $encodedDataArray[self::RAW_DIFF_INDEX]));
                } else {
                        // Send buffer size out
                        //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: MD5=' . md5(substr($encodedDataArray[self::RAW_ENCODED_DATA_INDEX], 0, $encodedDataArray[self::RAW_BUFFER_SIZE_INDEX])));
-                       $sentBytes = socket_write($encodedDataArray[self::RAW_SOCKET_INDEX], $encodedDataArray[self::RAW_ENCODED_DATA_INDEX], $encodedDataArray[self::RAW_BUFFER_SIZE_INDEX]);
+                       $sentBytes = @socket_write($encodedDataArray[self::RAW_SOCKET_INDEX], $encodedDataArray[self::RAW_ENCODED_DATA_INDEX], $encodedDataArray[self::RAW_BUFFER_SIZE_INDEX]);
                }
 
                // If there was an error, we don't continue here