From: Roland Haeder Date: Sat, 15 Feb 2014 23:13:06 +0000 (+0100) Subject: Needs to be an object attribute/field. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8d1e596fa175bde5ceefca944150c789df143590;p=hub.git Needs to be an object attribute/field. Signed-off-by: Roland Haeder --- diff --git a/application/hub/main/handler/network/tcp/class_TcpRawDataHandler.php b/application/hub/main/handler/network/tcp/class_TcpRawDataHandler.php index aedbb2693..73a128770 100644 --- a/application/hub/main/handler/network/tcp/class_TcpRawDataHandler.php +++ b/application/hub/main/handler/network/tcp/class_TcpRawDataHandler.php @@ -22,6 +22,11 @@ * along with this program. If not, see . */ class TcpRawDataHandler extends BaseRawDataHandler implements Networkable { + /** + * Last socket error (default: Success) + */ + private $lastSocketError = 0; + /** * Protected constructor * @@ -66,7 +71,7 @@ class TcpRawDataHandler extends BaseRawDataHandler implements Networkable { $this->setErrorCode(self::SOCKET_ERROR_UNHANDLED); // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: Handling TCP package from resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $socketArray[BasePool::SOCKET_ARRAY_CONN_TYPE] . ',last error=' . socket_strerror(socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: Handling TCP package from resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $socketArray[BasePool::SOCKET_ARRAY_CONN_TYPE] . ',last error=' . socket_strerror($this->lastSocketError)); /* * Read the raw data from socket. If you change PHP_BINARY_READ to @@ -76,14 +81,14 @@ class TcpRawDataHandler extends BaseRawDataHandler implements Networkable { $rawData = socket_read($socketArray[BasePool::SOCKET_ARRAY_RESOURCE], $this->getConfigInstance()->getConfigEntry('tcp_buffer_length'), PHP_BINARY_READ); // Get socket error code back - $socketError = socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]); + $this->lastSocketError = socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]); // Debug output of read data length - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: rawData[' . gettype($rawData) . ']=' . strlen($rawData) . ',MD5=' . md5($rawData) . ',resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',error=' . socket_strerror($socketError)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: rawData[' . gettype($rawData) . ']=' . strlen($rawData) . ',MD5=' . md5($rawData) . ',resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',error=' . socket_strerror($this->lastSocketError)); /* NOISY-DEBUG: */ if ($rawData !== FALSE) self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: rawData=' . $rawData); // Is it valid? - if ($socketError == 11) { + if ($this->lastSocketError == 11) { // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: Ignoring error 11 (Resource temporary unavailable) from socket resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE]); @@ -96,9 +101,9 @@ class TcpRawDataHandler extends BaseRawDataHandler implements Networkable { // Skip any further processing return; - } elseif (($rawData === FALSE) || ($socketError > 0)) { + } elseif (($rawData === FALSE) || ($this->lastSocketError > 0)) { // Network error or connection lost - $this->setErrorCode($socketError); + $this->setErrorCode($this->lastSocketError); } elseif (empty($rawData)) { // The peer did send nothing to us which is now being ignored return;