* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class TcpRawDataHandler extends BaseRawDataHandler implements Networkable {
+ /**
+ * Last socket error (default: Success)
+ */
+ private $lastSocketError = 0;
+
/**
* Protected constructor
*
$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
$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]);
// 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;