// Check if there was an error else
if ($errorNo > 0) {
// Then throw again
- throw new InvalidSocketException(array($helperInstance, $socketResource, $errorNo, $errorStr), BaseListener::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($helperInstance, $socketResource, $errorNo, $errorStr), self::EXCEPTION_INVALID_SOCKET);
} // END - if
// Check if there was an error else
if ($errorNo > 0) {
// Then throw again
- throw new InvalidSocketException(array($helperInstance, $socketResource, $errorNo, $errorStr), BaseListener::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($helperInstance, $socketResource, $errorNo, $errorStr), self::EXCEPTION_INVALID_SOCKET);
} // END - if
// Prepare the GET request
namespace Hub\Container\Socket;
// Import application-specific stuff
+use Hub\Handler\RawData\BaseRawDataHandler;
+use Hub\Helper\Connection\BaseConnectionHelper;
use Hub\Information\ShareableInfo;
use Hub\Listener\BaseListener;
use Hub\Network\Package\NetworkPackage;
// Import framework stuff
use CoreFramework\Container\BaseContainer;
+use CoreFramework\Factory\ObjectFactory;
use CoreFramework\Listener\Listenable;
use CoreFramework\Registry\Registerable;
use CoreFramework\Socket\InvalidSocketException;
use CoreFramework\Socket\NoSocketErrorDetectedException;
+use CoreFramework\Socket\SocketBindingException;
+use CoreFramework\Socket\SocketConnectionException;
+use CoreFramework\Socket\SocketOperationException;
+use CoreFramework\Socket\UnsupportedSocketErrorHandlerException;
use CoreFramework\Visitor\Visitable;
use CoreFramework\Visitor\Visitor;
* @param $socketResource A valid socket resource
* @param $infoInstance An instance of a ShareableInfo class
* @param $packageData Raw package data
- * @return $containerInstance An instance of this Container class
+ * @return $socketInstance An instance of this Container class
*/
public static final function createSocketContainer ($socketResource, ShareableInfo $infoInstance = NULL, array $packageData = array()) {
// Get a new instance
- $containerInstance = new SocketContainer();
+ $socketInstance = new SocketContainer();
// Remove unneeded entries
unset($packageData[NetworkPackage::PACKAGE_DATA_CONTENT]);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-CONTAINER: Setting listenerInstance=' . $listenerInstance->__toString() . ' ...');
// Set it here for later usage
- $containerInstance->setListenerInstance($listenerInstance);
+ $socketInstance->setListenerInstance($listenerInstance);
} elseif ($helperInstance instanceof ConnectionHelper) {
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-CONTAINER: Setting helperInstance=' . $helperInstance->__toString() . ' ...');
// Set it here for later usage
- $containerInstance->setHelperInstance($helperInstance);
+ $socketInstance->setHelperInstance($helperInstance);
}
} // END - if
// Set the resource ...
- $containerInstance->setSocketResource($socketResource);
+ $socketInstance->setSocketResource($socketResource);
// ... and package data
- $containerInstance->setPackageData($packageData);
+ $socketInstance->setPackageData($packageData);
// Return the prepared instance
- return $containerInstance;
+ return $socketInstance;
}
/**
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getProtocolName()) . '-SOCKET: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - EXIT!');
}
+ /**
+ * Some "getter" for peer address/port from stored socket
+ *
+ * @param $peerAddress Peer address being determined
+ * @param $peerPort Peer port being determined
+ * @return $result Result from asking for peer address
+ * @throws InvalidSocketException If socket is invalid
+ */
+ public function getSocketPeerName (&$peerAddress, &$peerPort) {
+ // Should be valid socket
+ if (!$this->isValidSocket()) {
+ // Throw exception
+ throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
+ } // END - if
+
+ // Init result
+ $result = FALSE;
+
+ /*
+ * Which type of socket is set? Please note that UDP sockets doesn't
+ * support socket_getpeername():
+ * http://de2.php.net/manual/en/function.socket-getpeername.php#35656
+ */
+ if ($this->getSocketType() == 'udp') {
+ // UDP is WIP:
+ $this->partialStub('UDP sockets are unfinished.');
+ } else {
+ // Use socket_getpeername()
+ $result = socket_getpeername($this->getSocketResource(), $peerAddress, $peerPort);
+ }
+
+ // Return result
+ return $result;
+ }
+
+ /**
+ * Some "getter" for socket type of stored socket
+ *
+ * @return $socketType Socket type
+ * @throws InvalidSocketException If socket is invalid
+ */
+ public function getSocketType () {
+ // Should be valid socket
+ if (!$this->isValidSocket()) {
+ // Throw exception
+ throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
+ } // END - if
+
+ // Get socket protocol first
+ $socketProtocol = $this->getSocketProtocol();
+
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-CONTAINER: socketProtocol[%s]=%s', gettype($socketProtocol), $socketProtocol));
+
+ // Get socket option
+ $socketType = socket_get_option($this->getSocketResource(), getprotobyname($socketProtocol), SO_TYPE);
+
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-CONTAINER: socketType[%s]=%s', gettype($socketType), $socketType));
+
+ // Is it valid?
+ if ($socketType === FALSE) {
+ // Something went wrong
+ $this->handleSocketError(__METHOD__, __LINE__, array('null', '0'));
+ } // END - if
+ }
+
/**
* Validates stored stocket
*
// Should be valid socket
if (!$this->isValidSocket()) {
// Throw exception
- throw new InvalidSocketException(array($this, $this->getSocketResource()), BaseListener::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
} // END - if
// Get it from stored socket resource
return $errorCode;
}
+ /**
+ * Getter for last socket error message
+ *
+ * @return $lastSocketErrorMessage Last socket error message
+ * @throws InvalidSocketException If socket is invalid
+ */
+ public function getLastSocketErrorMessage () {
+ // Should be valid socket
+ if (!$this->isValidSocket()) {
+ // Throw exception
+ throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
+ } // END - if
+
+ // Get it from stored socket resource
+ $socketResource = $this->getSocketResource();
+
+ // Get error code and message
+ $message = socket_strerror(socket_last_error($socketResource));
+
+ // Return it
+ return $message;
+ }
+
/**
* Tries to bind the socket.
*
// Should be valid socket
if (!$this->isValidSocket()) {
// Throw exception
- throw new InvalidSocketException(array($this, $this->getSocketResource()), BaseListener::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
} // END - if
// Try to bind it to
* Tries to listen on the socket
*
* @return $result Result from listening on socket
- * @throws InvalidSocketException If socket is valid
+ * @throws InvalidSocketException If stored socket is invalid
*/
public function listenOnSocket () {
// Should be valid socket
if (!$this->isValidSocket()) {
// Throw exception
- throw new InvalidSocketException(array($this, $this->getSocketResource()), BaseListener::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
} // END - if
// Try to listen on socket
* Tries to set non-blocking I/O on stored socket
*
* @return $result Result of changing to non-blocking I/O
- * @throws InvalidSocketException If socket is valid
+ * @throws InvalidSocketException If stored socket is invalid
*/
public function enableSocketNonBlocking () {
// Should be valid socket
if (!$this->isValidSocket()) {
// Throw exception
- throw new InvalidSocketException(array($this, $this->getSocketResource()), BaseListener::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
} // END - if
// Try to set non-blocking I/O
// This method handles only socket resources
if (!$this->isValidSocket()) {
// No resource, abort here
- throw new InvalidSocketException(array($this, $this->getSocketResource()), BaseListener::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
} // END - if
// Check socket array, 1st element is mostly IP address (or file name), 2nd is port number
$handlerName = $this->getSocketErrorHandlerFromCode($errorCode);
// Call-back the error handler method
- call_user_func_array(array($this, $handlerName), array($this, $socketData));
+ call_user_func_array(array($this, $handlerName), array($socketData));
// Finally clear the error because it has been handled
$this->clearLastSocketError();
}
+ /**
+ * Translates socket error codes into our own internal names which can be
+ * used for call-backs.
+ *
+ * @param $errorCode The error code from socket_last_error() to be translated
+ * @return $errorName The translated name (all lower-case, with underlines)
+ */
+ public function translateSocketErrorCodeToName ($errorCode) {
+ // Nothing bad happened by default
+ $errorName = StorableSocket::SOCKET_CONNECTED;
+
+ // Is the code a number, then we have to change it
+ switch ($errorCode) {
+ case 0: // Silently ignored, the socket is connected
+ break;
+
+ case 11: // "Resource temporary unavailable"
+ $errorName = StorableSocket::SOCKET_ERROR_RESOURCE_UNAVAILABLE;
+ break;
+
+ case 13: // "Permission denied"
+ $errorName = StorableSocket::SOCKET_ERROR_PERMISSION_DENIED;
+ break;
+
+ case 32: // "Broken pipe"
+ $errorName = StorableSocket::SOCKET_ERROR_BROKEN_PIPE;
+ break;
+
+ case 95: // "Operation not supported"
+ $errorName = StorableSocket::SOCKET_ERROR_OPERATION_NOT_SUPPORTED;
+ break;
+
+ case 104: // "Connection reset by peer"
+ $errorName = StorableSocket::SOCKET_ERROR_CONNECTION_RESET_BY_PEER;
+ break;
+
+ case 107: // "Transport end-point not connected"
+ case 134: // On some (?) systems for 'transport end-point not connected'
+ // @TODO On some systems it is 134, on some 107?
+ $errorName = StorableSocket::SOCKET_ERROR_TRANSPORT_ENDPOINT;
+ break;
+
+ case 110: // "Connection timed out"
+ $errorName = StorableSocket::SOCKET_ERROR_CONNECTION_TIMED_OUT;
+ break;
+
+ case 111: // "Connection refused"
+ $errorName = StorableSocket::SOCKET_ERROR_CONNECTION_REFUSED;
+ break;
+
+ case 113: // "No route to host"
+ $errorName = StorableSocket::SOCKET_ERROR_NO_ROUTE_TO_HOST;
+ break;
+
+ case 114: // "Operation already in progress"
+ $errorName = StorableSocket::SOCKET_ERROR_OPERATION_ALREADY_PROGRESS;
+ break;
+
+ case 115: // "Operation now in progress"
+ $errorName = StorableSocket::SOCKET_ERROR_OPERATION_IN_PROGRESS;
+ break;
+
+ default: // Everything else <> 0
+ // Unhandled error code detected, so first debug it because we may want to handle it like the others
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-CONTAINER: Unsupported errorCode=%d,message=%s', $errorCode, socket_strerror($errorCode)));
+
+ // Change it only in this class
+ $errorName = StorableSocket::SOCKET_ERROR_UNKNOWN;
+ break;
+ } // END - switch
+
+ // Return translated name
+ return $errorName;
+ }
+
+ /**
+ * Constructs a callable method name from given socket error code. If the
+ * method is not found, a generic one is used.
+ *
+ * @param $errorCode Error code from socket_last_error()
+ * @return $handlerName Call-back method name for the error handler
+ * @throws UnsupportedSocketErrorHandlerException If the error handler is not implemented
+ */
+ protected function getSocketErrorHandlerFromCode ($errorCode) {
+ // Create a name from translated error code
+ $handlerName = 'handleSocketError' . self::convertToClassName($this->translateSocketErrorCodeToName($errorCode));
+
+ // Is the call-back method there?
+ if (!method_exists($this, $handlerName)) {
+ // Please implement this
+ throw new UnsupportedSocketErrorHandlerException(array($this, $handlerName, $errorCode), BaseConnectionHelper::EXCEPTION_UNSUPPORTED_ERROR_HANDLER);
+ } // END - if
+
+ // Return it
+ return $handlerName;
+ }
+
+ /************************************************************************
+ * Socket error handler call-back methods *
+ ************************************************************************/
+
+ /**
+ * 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) {
+ // Get socket error code for verification
+ $socketError = $this->getLastSocketError();
+
+ // Get error message
+ $errorMessage = $this->getLastSocketErrorMessage();
+
+ // Shutdown this socket
+ $this->shutdownSocket();
+
+ // Throw it again
+ throw new SocketBindingException(array($this, $socketData, $this->getSocketResource(), $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET);
+ }
+
+ /**
+ * Handles socket error 'connection timed out', but does not clear it for
+ * later debugging purposes.
+ *
+ * @param $unlData A valid UNL data array
+ * @return void
+ * @throws SocketConnectionException The connection attempts fails with a time-out
+ */
+ protected function handleSocketErrorConnectionTimedOut (array $unlData) {
+ // Get socket error code for verification
+ $socketError = $this->getLastSocketError();
+
+ // Get error message
+ $errorMessage = $this->getLastSocketErrorMessage();
+
+ // Shutdown this socket
+ $this->shutdownSocket();
+
+ // Throw it again
+ throw new SocketConnectionException(array($this, $this->getSocketResource(), $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET);
+ }
+
+ /**
+ * Handles socket error 'resource temporary unavailable', but does not
+ * clear it for later debugging purposes.
+ *
+ * @param $unlData A valid UNL data array
+ * @return void
+ * @throws SocketConnectionException The connection attempts fails with a time-out
+ */
+ protected function handleSocketErrorResourceUnavailable (array $unlData) {
+ // Get socket error code for verification
+ $socketError = $this->getLastSocketError();
+
+ // Get error message
+ $errorMessage = $this->getLastSocketErrorMessage();
+
+ // Shutdown this socket
+ $this->shutdownSocket();
+
+ // Throw it again
+ throw new SocketConnectionException(array($this, $this->getSocketResource(), $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET);
+ }
+
+ /**
+ * Handles socket error 'connection refused', but does not clear it for
+ * later debugging purposes.
+ *
+ * @param $unlData A valid UNL data array
+ * @return void
+ * @throws SocketConnectionException The connection attempts fails with a time-out
+ */
+ protected function handleSocketErrorConnectionRefused (array $unlData) {
+ // Get socket error code for verification
+ $socketError = $this->getLastSocketError();
+
+ // Get error message
+ $errorMessage = $this->getLastSocketErrorMessage();
+
+ // Shutdown this socket
+ $this->shutdownSocket();
+
+ // Throw it again
+ throw new SocketConnectionException(array($this, $this->getSocketResource(), $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET);
+ }
+
+ /**
+ * Handles socket error 'no route to host', but does not clear it for later
+ * debugging purposes.
+ *
+ * @param $unlData A valid UNL data array
+ * @return void
+ * @throws SocketConnectionException The connection attempts fails with a time-out
+ */
+ protected function handleSocketErrorNoRouteToHost (array $unlData) {
+ // Get socket error code for verification
+ $socketError = $this->getLastSocketError();
+
+ // Get error message
+ $errorMessage = $this->getLastSocketErrorMessage();
+
+ // Shutdown this socket
+ $this->shutdownSocket();
+
+ // Throw it again
+ throw new SocketConnectionException(array($this, $this->getSocketResource(), $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET);
+ }
+
+ /**
+ * Handles socket error 'operation already in progress' which happens in
+ * method connectToPeerByUnlData() on timed out connection
+ * attempts.
+ *
+ * @param $unlData A valid UNL data array
+ * @return void
+ * @throws SocketConnectionException The connection attempts fails with a time-out
+ */
+ protected function handleSocketErrorOperationAlreadyProgress (array $unlData) {
+ // Get socket error code for verification
+ $socketError = $this->getLastSocketError();
+
+ // Get error message
+ $errorMessage = $this->getLastSocketErrorMessage();
+
+ // Half-shutdown this socket (see there for difference to shutdownSocket())
+ $this->halfShutdownSocket();
+
+ // Throw it again
+ throw new SocketConnectionException(array($this, $this->getSocketResource(), $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET);
+ }
+
+ /**
+ * Handles socket error 'connection reset by peer', but does not clear it for
+ * later debugging purposes.
+ *
+ * @param $unlData A valid UNL data array
+ * @return void
+ * @throws SocketConnectionException The connection attempts fails with a time-out
+ */
+ protected function handleSocketErrorConnectionResetByPeer (array $unlData) {
+ // Get socket error code for verification
+ $socketError = $this->getLastSocketError();
+
+ // Get error message
+ $errorMessage = $this->getLastSocketErrorMessage();
+
+ // Shutdown this socket
+ $this->shutdownSocket();
+
+ // Throw it again
+ throw new SocketConnectionException(array($this, $this->getSocketResource(), $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET);
+ }
+
+ /**
+ * Handles socket error 'operation not supported', but does not clear it for
+ * later debugging purposes.
+ *
+ * @param $unlData A valid UNL data array
+ * @return void
+ * @throws SocketOperationException The connection attempts fails with a time-out
+ */
+ protected function handleSocketErrorOperationNotSupported (array $unlData) {
+ // Get socket error code for verification
+ $socketError = $this->getLastSocketError();
+
+ // Get error message
+ $errorMessage = $this->getLastSocketErrorMessage();
+
+ // Shutdown this socket
+ $this->shutdownSocket();
+
+ // Throw it again
+ throw new SocketOperationException(array($this, $this->getSocketResource(), $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET);
+ }
+
+ /**
+ * Handles socket "error" 'operation now in progress' which can be safely
+ * passed on with non-blocking connections.
+ *
+ * @param $unlData A valid UNL data array
+ * @return void
+ */
+ protected function handleSocketErrorOperationInProgress (array $unlData) {
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Operation is now in progress, this is usual for non-blocking connections and is no bug.');
+ }
+
}
$lastError = socket_last_error($socketResource);
// Doesn't work!
- throw new InvalidSocketException(array($this, $socketResource, $lastError, socket_strerror($lastError)), SocketHandler::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($this, $socketResource, $lastError, socket_strerror($lastError)), self::EXCEPTION_INVALID_SOCKET);
} // END - if
// Debug message
// Is the socket resource valid?
if (!$socketInstance->isValidSocket()) {
// Something bad happened
- throw new InvalidSocketException(array($listenerInstance, $socketInstance->getSocketResource()), BaseListener::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($listenerInstance, $socketInstance->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
} // END - if
// Get socket error code for verification
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class BaseRawDataHandler extends BaseHandler {
- // Error codes:
- // - Socket raw data stream errors
- const SOCKET_ERROR_UNKNOWN = 'unknown_error'; // Unknown error (should not happen)
- const SOCKET_ERROR_TRANSPORT_ENDPOINT = 'transport_endpoint'; // Transport endpoint has closed
- const SOCKET_ERROR_INVALID_BASE64_MODULO = 'base64_modulo'; // Length is not modulo 4
- const SOCKET_ERROR_INVALID_BASE64_MESSAGE = 'base64_message'; // Raw data is not Base64-encoded
- const SOCKET_ERROR_UNHANDLED = 'unhandled_package'; // Unhandled raw data (not bad)
- const SOCKET_ERROR_CONNECTION_REFUSED = 'connection_refused'; // The name says it: connection refused
- const SOCKET_ERROR_CONNECTION_TIMED_OUT = 'connection_timed_out'; // The name says it: connection attempt has timed-out
- const SOCKET_ERROR_OPERATION_IN_PROGRESS = 'operation_in_progress'; // 'Operation now in progress'
- 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 = 'connection_reset_by_peer'; // Connection reset by peer
- const SOCKET_ERROR_BROKEN_PIPE = 'broken_pipe'; // Broken pipe
- const SOCKET_ERROR_PERMISSION_DENIED = 'permission_denied'; // Permission denied
- const SOCKET_CONNECTED = 'connected'; // Nothing errorous happens, socket is connected
-
// - Package errors
const PACKAGE_ERROR_INVALID_DATA = 'invalid_data'; // Invalid data in package found
const PACKAGE_ERROR_INCOMPLETE_DATA = 'incomplete_data'; // Incomplete data sent (e.g. field is missing)
$this->initSocketInstance();
}
- // ************************************************************************
- // Socket error handler call-back methods
- // ************************************************************************
-
- /**
- * Handles socket error 'connection timed out', but does not clear it for
- * later debugging purposes.
- *
- * @param $socketInstance An instance of a StorableSocket class
- * @param $unlData A valid UNL data array
- * @return void
- * @throws SocketConnectionException The connection attempts fails with a time-out
- */
- protected function socketErrorConnectionTimedOutHandler (StorableSocket $socketInstance, array $unlData) {
- // Get socket error code for verification
- $socketError = $socketInstance->getLastSocketError();
-
- // Get error message
- $errorMessage = $socketInstance->getLastSocketErrorMessage();
-
- // Shutdown this socket
- $socketInstance->shutdownSocket();
-
- // Throw it again
- throw new SocketConnectionException(array($this, $socketInstance, $socketError, $errorMessage), SocketHandler::EXCEPTION_INVALID_SOCKET);
- }
-
- /**
- * Handles socket error 'resource temporary unavailable', but does not
- * clear it for later debugging purposes.
- *
- * @param $socketInstance An instance of a StorableSocket class
- * @param $unlData A valid UNL data array
- * @return void
- * @throws SocketConnectionException The connection attempts fails with a time-out
- */
- protected function socketErrorResourceUnavailableHandler (StorableSocket $socketInstance, array $unlData) {
- // Get socket error code for verification
- $socketError = $socketInstance->getLastSocketError();
-
- // Get error message
- $errorMessage = $socketInstance->getLastSocketErrorMessage();
-
- // Shutdown this socket
- $socketInstance->shutdownSocket();
-
- // Throw it again
- throw new SocketConnectionException(array($this, $socketInstance, $socketError, $errorMessage), SocketHandler::EXCEPTION_INVALID_SOCKET);
- }
-
- /**
- * Handles socket error 'connection refused', but does not clear it for
- * later debugging purposes.
- *
- * @param $socketInstance An instance of a StorableSocket class
- * @param $unlData A valid UNL data array
- * @return void
- * @throws SocketConnectionException The connection attempts fails with a time-out
- */
- protected function socketErrorConnectionRefusedHandler (StorableSocket $socketInstance, array $unlData) {
- // Get socket error code for verification
- $socketError = $socketInstance->getLastSocketError();
-
- // Get error message
- $errorMessage = $socketInstance->getLastSocketErrorMessage();
-
- // Shutdown this socket
- $socketInstance->shutdownSocket();
-
- // Throw it again
- throw new SocketConnectionException(array($this, $socketInstance, $socketError, $errorMessage), SocketHandler::EXCEPTION_INVALID_SOCKET);
- }
-
- /**
- * Handles socket error 'no route to host', but does not clear it for later
- * debugging purposes.
- *
- * @param $socketInstance An instance of a StorableSocket class
- * @param $unlData A valid UNL data array
- * @return void
- * @throws SocketConnectionException The connection attempts fails with a time-out
- */
- protected function socketErrorNoRouteToHostHandler (StorableSocket $socketInstance, array $unlData) {
- // Get socket error code for verification
- $socketError = $socketInstance->getLastSocketError();
-
- // Get error message
- $errorMessage = $socketInstance->getLastSocketErrorMessage();
-
- // Shutdown this socket
- $socketInstance->shutdownSocket();
-
- // Throw it again
- throw new SocketConnectionException(array($this, $socketInstance, $socketError, $errorMessage), SocketHandler::EXCEPTION_INVALID_SOCKET);
- }
-
- /**
- * Handles socket error 'operation already in progress' which happens in
- * method connectToPeerByUnlData() on timed out connection
- * attempts.
- *
- * @param $socketInstance An instance of a StorableSocket class
- * @param $unlData A valid UNL data array
- * @return void
- * @throws SocketConnectionException The connection attempts fails with a time-out
- */
- protected function socketErrorOperationAlreadyProgressHandler (StorableSocket $socketInstance, array $unlData) {
- // Get socket error code for verification
- $socketError = $socketInstance->getLastSocketError();
-
- // Get error message
- $errorMessage = $socketInstance->getLastSocketErrorMessage();
-
- // Half-shutdown this socket (see there for difference to shutdownSocket())
- $socketInstance->halfShutdownSocket();
-
- // Throw it again
- throw new SocketConnectionException(array($this, $socketInstance, $socketError, $errorMessage), SocketHandler::EXCEPTION_INVALID_SOCKET);
- }
-
- /**
- * Handles socket error 'connection reset by peer', but does not clear it for
- * later debugging purposes.
- *
- * @param $socketInstance An instance of a StorableSocket class
- * @param $unlData A valid UNL data array
- * @return void
- * @throws SocketConnectionException The connection attempts fails with a time-out
- */
- protected function socketErrorConnectionResetByPeerHandler (StorableSocket $socketInstance, array $unlData) {
- // Get socket error code for verification
- $socketError = $socketInstance->getLastSocketError();
-
- // Get error message
- $errorMessage = $socketInstance->getLastSocketErrorMessage();
-
- // Shutdown this socket
- $socketInstance->shutdownSocket();
-
- // Throw it again
- throw new SocketConnectionException(array($this, $socketInstance, $socketError, $errorMessage), SocketHandler::EXCEPTION_INVALID_SOCKET);
- }
-
- /**
- * Handles socket "error" 'operation now in progress' which can be safely
- * passed on with non-blocking connections.
- *
- * @param $socketInstance An instance of a StorableSocket class
- * @param $unlData A valid UNL data array
- * @return void
- */
- protected function socketErrorOperationInProgressHandler (StorableSocket $socketInstance, array $unlData) {
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Operation is now in progress, this is usual for non-blocking connections and is no bug.');
- }
}
-
-// [EOF]
-?>
* possible here because that method would throw an
* InvalidSocketException back.
*/
- throw new SocketCreationException(array($helperInstance, gettype($socketResource)), SocketHandler::EXCEPTION_SOCKET_CREATION_FAILED);
+ throw new SocketCreationException(array($helperInstance, gettype($socketResource)), StorableSocket::EXCEPTION_SOCKET_CREATION_FAILED);
} // END - if
// Get socket error code for verification
$helperInstance->handleSocketError(__METHOD__, __LINE__, $socketResource, array('0.0.0.0', '0'));
// Then throw again
- throw new SocketCreationException(array($helperInstance, gettype($socketResource), $socketError, socket_strerror($socketError)), SocketHandler::EXCEPTION_SOCKET_CREATION_FAILED);
+ throw new SocketCreationException(array($helperInstance, gettype($socketResource), $socketError, socket_strerror($socketError)), StorableSocket::EXCEPTION_SOCKET_CREATION_FAILED);
} // END - if
// Debug message
// Could not shutdown socket, this is fine if e.g. the other side is not connected, so analyse it
if (socket_last_error($this->getSocketResource()) != 107) {
// Something bad happened while we shutdown a socket
- throw new SocketShutdownException($this, SocketHandler::EXCEPTION_INVALID_SOCKET);
+ throw new SocketShutdownException($this, self::EXCEPTION_INVALID_SOCKET);
} // END - if
} // END - if
use Hub\Container\Socket\StorableSocket;
use Hub\Factory\Information\Connection\ConnectionInfoFactory;
use Hub\Generic\BaseHubSystem;
-use Hub\Handler\RawData\BaseRawDataHandler;
use Hub\Helper\Connection\BaseConnectionHelper;
use Hub\Network\Package\NetworkPackage;
use Hub\Pool\Peer\PoolablePeer;
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
- /**
- * Constructs a callable method name from given socket error code. If the
- * method is not found, a generic one is used.
- *
- * @param $errorCode Error code from socket_last_error()
- * @return $handlerName Call-back method name for the error handler
- * @throws UnsupportedSocketErrorHandlerException If the error handler is not implemented
- */
- protected function getSocketErrorHandlerFromCode ($errorCode) {
- // Create a name from translated error code
- $handlerName = 'socketError' . self::convertToClassName($this->translateSocketErrorCodeToName($errorCode)) . 'Handler';
-
- // Is the call-back method there?
- if (!method_exists($this, $handlerName)) {
- // Please implement this
- throw new UnsupportedSocketErrorHandlerException(array($this, $handlerName, $errorCode), BaseConnectionHelper::EXCEPTION_UNSUPPORTED_ERROR_HANDLER);
- } // END - if
-
- // Return it
- return $handlerName;
- }
-
- /**
- * Translates socket error codes into our own internal names which can be
- * used for call-backs.
- *
- * @param $errorCode The error code from socket_last_error() to be translated
- * @return $errorName The translated name (all lower-case, with underlines)
- */
- public function translateSocketErrorCodeToName ($errorCode) {
- // Nothing bad happened by default
- $errorName = BaseRawDataHandler::SOCKET_CONNECTED;
-
- // Is the code a number, then we have to change it
- switch ($errorCode) {
- case 0: // Silently ignored, the socket is connected
- break;
-
- case 11: // "Resource temporary unavailable"
- $errorName = BaseRawDataHandler::SOCKET_ERROR_RESOURCE_UNAVAILABLE;
- break;
-
- case 13: // "Permission denied"
- $errorName = BaseRawDataHandler::SOCKET_ERROR_PERMISSION_DENIED;
- break;
-
- case 32: // "Broken pipe"
- $errorName = BaseRawDataHandler::SOCKET_ERROR_BROKEN_PIPE;
- break;
-
- case 104: // "Connection reset by peer"
- $errorName = BaseRawDataHandler::SOCKET_ERROR_CONNECTION_RESET_BY_PEER;
- break;
-
- case 107: // "Transport end-point not connected"
- case 134: // On some (?) systems for 'transport end-point not connected'
- // @TODO On some systems it is 134, on some 107?
- $errorName = BaseRawDataHandler::SOCKET_ERROR_TRANSPORT_ENDPOINT;
- break;
-
- case 110: // "Connection timed out"
- $errorName = BaseRawDataHandler::SOCKET_ERROR_CONNECTION_TIMED_OUT;
- break;
-
- case 111: // "Connection refused"
- $errorName = BaseRawDataHandler::SOCKET_ERROR_CONNECTION_REFUSED;
- break;
-
- case 113: // "No route to host"
- $errorName = BaseRawDataHandler::SOCKET_ERROR_NO_ROUTE_TO_HOST;
- break;
-
- case 114: // "Operation already in progress"
- $errorName = BaseRawDataHandler::SOCKET_ERROR_OPERATION_ALREADY_PROGRESS;
- break;
-
- case 115: // "Operation now in progress"
- $errorName = BaseRawDataHandler::SOCKET_ERROR_OPERATION_IN_PROGRESS;
- break;
-
- default: // Everything else <> 0
- // Unhandled error code detected, so first debug it because we may want to handle it like the others
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-HUB UNKNOWN ERROR CODE = ' . $errorCode . ', MESSAGE = ' . socket_strerror($errorCode));
-
- // Change it only in this class
- $errorName = BaseRawDataHandler::SOCKET_ERROR_UNKNOWN;
- break;
- }
-
- // Return translated name
- return $errorName;
- }
-
/**
* "Listens" for incoming network packages
*
$this->getIteratorInstance()->next();
}
- // ************************************************************************
- // Socket error handler call-back methods
- // ************************************************************************
-
- /**
- * Handles socket error 'permission denied', but does not clear it for
- * later debugging purposes.
- *
- * @param $socketInstance An instance of a StorableSocket class
- * @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 socketErrorPermissionDeniedHandler (StorableSocket $socketInstance, array $socketData) {
- // Get socket error code for verification
- $socketError = $socketInstance->getLastSocketError();
-
- // Get error message
- $errorMessage = $socketInstance->getLastSocketErrorMessage();
-
- // Shutdown this socket
- $socketInstance->shutdownSocket();
-
- // Throw it again
- throw new SocketBindingException(array($this, $socketData, $socketInstance, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
- }
-
}
// Is the socket resource valid?
if (!is_resource($mainSocket)) {
// Something bad happened
- throw new InvalidSocketException(array($this, $mainSocket), SocketHandler::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($this, $mainSocket), self::EXCEPTION_INVALID_SOCKET);
} // END - if
// Get socket error code for verification
$this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0'));
/*
// Then throw again
- throw new InvalidSocketException(array($this, $mainSocket, $socketError, socket_strerror($socketError)), SocketHandler::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($this, $mainSocket, $socketError, socket_strerror($socketError)), self::EXCEPTION_INVALID_SOCKET);
*/
} // END - if
$this->shutdownSocket($mainSocket);
// And throw again
- throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), SocketHandler::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET);
*/
} // END - if
$this->shutdownSocket($mainSocket);
// And throw again
- throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), SocketHandler::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET);
*/
} // END - if
$this->shutdownSocket($mainSocket);
// And throw again
- throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), SocketHandler::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET);
*/
} // END - if
$this->shutdownSocket($mainSocket);
// And throw again
- throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), SocketHandler::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($this, $mainSocket, $socketError, $errorMessage), self::EXCEPTION_INVALID_SOCKET);
*/
} // END - if
// Is the socket a valid resource or do we have any error?
if (!is_resource($mainSocket)) {
// Then throw an InvalidSocketException
- throw new InvalidSocketException(array($this, $mainSocket), SocketHandler::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($this, $mainSocket), self::EXCEPTION_INVALID_SOCKET);
} // END - if
/*
namespace Hub\Network\Package\Assembler;
// Import hub-specific stuff
+use Hub\Container\Socket\StorableSocket;
use Hub\Generic\BaseHubSystem;
use Hub\Handler\RawData\BaseRawDataHandler;
use Hub\Network\Package\NetworkPackage;
// Init fake array
$packageContent = array(
BaseRawDataHandler::PACKAGE_RAW_DATA => $this->getInputStreamInstance()->streamData($this->pendingData),
- BaseRawDataHandler::PACKAGE_ERROR_CODE => BaseRawDataHandler::SOCKET_ERROR_UNHANDLED
+ BaseRawDataHandler::PACKAGE_ERROR_CODE => StorableSocket::SOCKET_ERROR_UNHANDLED
);
/*
* Also make sure the error code is SOCKET_ERROR_UNHANDLED because we
* only want to handle unhandled packages here.
*/
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: errorCode=' . $decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] . '(' . BaseRawDataHandler::SOCKET_ERROR_UNHANDLED . ')');
- assert($decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] == BaseRawDataHandler::SOCKET_ERROR_UNHANDLED);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: errorCode=' . $decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] . '(' . StorableSocket::SOCKET_ERROR_UNHANDLED . ')');
+ assert($decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] == StorableSocket::SOCKET_ERROR_UNHANDLED);
// Remove the last chunk SEPARATOR (because there is no need for it)
if (substr($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA], -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) {
// Is it a valid resource?
if (!$socketInstance->isValidSocket()) {
// Throw an exception
- throw new InvalidSocketException(array($this, $socketInstance->getSocketResource()), SocketHandler::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($this, $socketInstance->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
} // END - if
// Get error code
// Still no socket resource?
if (!$socketInstance->isValidSocket())) {
// Then abort here with an exception (may happen after socket_shutdown())
- throw new InvalidSocketException(array($helperInstance, $socketInstance->getSocketResource()), SocketHandler::EXCEPTION_INVALID_SOCKET);
+ throw new InvalidSocketException(array($helperInstance, $socketInstance->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
} // END - if
} // END - if
namespace Hub\State\Peer;
// Import application-specific stuff
-use Hub\Handler\RawData\BaseRawDataHandler;
+use Hub\Container\Socket\StorableSocket;
// Import framework stuff
use CoreFramework\State\Stateable;
parent::__construct(__CLASS__);
// Set state name
- $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_!!!);
+ $this->setStateName(StorableSocket::SOCKET_ERROR_!!!);
}
/**
// Own namespace
namespace Hub\State\Peer;
+// Import application-specific stuff
+use Hub\Container\Socket\StorableSocket;
+
// Import framework stuff
use CoreFramework\State\Stateable;
parent::__construct(__CLASS__);
// Set state name
- $this->setStateName(BaseRawDataHandler::SOCKET_CONNECTED);
+ $this->setStateName(StorableSocket::SOCKET_CONNECTED);
}
/**
namespace Hub\State\Peer;
// Import application-specific stuff
-use Hub\Handler\RawData\BaseRawDataHandler;
+use Hub\Container\Socket\StorableSocket;
// Import framework stuff
use CoreFramework\State\Stateable;
parent::__construct(__CLASS__);
// Set state name
- $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_CONNECTION_REFUSED);
+ $this->setStateName(StorableSocket::SOCKET_ERROR_CONNECTION_REFUSED);
}
/**
namespace Hub\State\Peer;
// Import application-specific stuff
-use Hub\Handler\RawData\BaseRawDataHandler;
+use Hub\Container\Socket\StorableSocket;
// Import framework stuff
use CoreFramework\State\Stateable;
parent::__construct(__CLASS__);
// Set state name
- $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_CONNECTION_TIMED_OUT);
+ $this->setStateName(StorableSocket::SOCKET_ERROR_CONNECTION_TIMED_OUT);
}
/**
namespace Hub\State\Peer;
// Import application-specific stuff
-use Hub\Handler\RawData\BaseRawDataHandler;
+use Hub\Container\Socket\StorableSocket;
// Import framework stuff
use CoreFramework\State\Stateable;
parent::__construct(__CLASS__);
// Set state name
- $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_NO_ROUTE_TO_HOST);
+ $this->setStateName(StorableSocket::SOCKET_ERROR_NO_ROUTE_TO_HOST);
}
/**
namespace Hub\State\Peer;
// Import application-specific stuff
-use Hub\Handler\RawData\BaseRawDataHandler;
+use Hub\Container\Socket\StorableSocket;
// Import framework stuff
use CoreFramework\State\Stateable;
parent::__construct(__CLASS__);
// Set state name
- $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_OPERATION_ALREADY_PROGRESS);
+ $this->setStateName(StorableSocket::SOCKET_ERROR_OPERATION_ALREADY_PROGRESS);
}
/**
namespace Hub\State\Peer;
// Import application-specific stuff
-use Hub\Handler\RawData\BaseRawDataHandler;
+use Hub\Container\Socket\StorableSocket;
// Import framework stuff
use CoreFramework\State\Stateable;
parent::__construct(__CLASS__);
// Set state name
- $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_UNKNOWN);
+ $this->setStateName(StorableSocket::SOCKET_ERROR_UNKNOWN);
}
/**
namespace Hub\State\Peer;
// Import application-specific stuff
-use Hub\Handler\RawData\BaseRawDataHandler;
+use Hub\Container\Socket\StorableSocket;
// Import framework stuff
use CoreFramework\State\Stateable;
parent::__construct(__CLASS__);
// Set state name
- $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_TRANSPORT_ENDPOINT);
+ $this->setStateName(StorableSocket::SOCKET_ERROR_TRANSPORT_ENDPOINT);
}
/**
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
interface StorableSocket extends FrameworkInterface {
+ // Error codes:
+ // - Socket raw data stream errors
+ const SOCKET_ERROR_UNKNOWN = 'unknown_error'; // Unknown error (should not happen)
+ const SOCKET_ERROR_TRANSPORT_ENDPOINT = 'transport_endpoint'; // Transport endpoint has closed
+ const SOCKET_ERROR_INVALID_BASE64_MODULO = 'base64_modulo'; // Length is not modulo 4
+ const SOCKET_ERROR_INVALID_BASE64_MESSAGE = 'base64_message'; // Raw data is not Base64-encoded
+ const SOCKET_ERROR_UNHANDLED = 'unhandled_package'; // Unhandled raw data (not bad)
+ const SOCKET_ERROR_CONNECTION_REFUSED = 'connection_refused'; // The name says it: connection refused
+ const SOCKET_ERROR_CONNECTION_TIMED_OUT = 'connection_timed_out'; // The name says it: connection attempt has timed-out
+ const SOCKET_ERROR_OPERATION_IN_PROGRESS = 'operation_in_progress'; // 'Operation now in progress'
+ 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 = 'connection_reset_by_peer'; // Connection reset by peer
+ const SOCKET_ERROR_BROKEN_PIPE = 'broken_pipe'; // Broken pipe
+ const SOCKET_ERROR_PERMISSION_DENIED = 'permission_denied'; // Permission denied
+ const SOCKET_ERROR_OPERATION_NOT_SUPPORTED = 'operation_not_supported'; // 'Operation not supported'
+ const SOCKET_CONNECTED = 'connected'; // Nothing errorous happens, socket is connected
+
+ /**
+ * Tries to bind the socket.
+ *
+ * @param $bindAddress Where to bind the socket to (e.g. Uni* socket file)
+ * @return $result Result from binding socket
+ * @throws InvalidSocketException If stored socket is invalid
+ */
+ function bindSocketTo ($bindAddress);
+
+ /**
+ * Tries to listen on the socket
+ *
+ * @return $result Result from listening on socket
+ * @throws InvalidSocketException If stored socket is invalid
+ */
+ function listenOnSocket ();
+
+ /**
+ * Tries to set non-blocking I/O on stored socket
+ *
+ * @return $result Result of changing to non-blocking I/O
+ * @throws InvalidSocketException If stored socket is invalid
+ */
+ function enableSocketNonBlocking ();
+
+ /**
+ * Some "getter" for peer address/port from stored socket
+ *
+ * @param $peerAddress Peer address being determined
+ * @param $peerPort Peer port being determined
+ * @return $result Result from asking for peer address
+ * @throws InvalidSocketException If stored socket is invalid
+ */
+ function getSocketPeerName (&$peerAddress, &$peerPort);
+
+ /**
+ * Some "getter" for socket type of stored socket
+ *
+ * @return $socketType Socket type
+ */
+ function getSocketType ();
/**
* Checks whether the given Universal Node Locator matches with the one from package data
* Getter for last socket error
*
* @return $lastSocketError Last socket error
- * @throws InvalidSocketException If socket is valid
+ * @throws InvalidSocketException If stored socket is invalid
*/
function getLastSocketError ();
/**
- * Tries to bind the socket.
- *
- * @param $bindAddress Where to bind the socket to (e.g. Uni* socket file)
- * @return $result Result from binding socket
- * @throws InvalidSocketException If socket is valid
- */
- function bindSocketTo ($bindAddress);
-
- /**
- * Tries to listen on the socket
- *
- * @return $result Result from listening on socket
- * @throws InvalidSocketException If socket is valid
- */
- function listenOnSocket ();
-
- /**
- * Tries to set non-blocking I/O on stored socket
+ * Getter for last socket error message
*
- * @return $result Result of changing to non-blocking I/O
- * @throws InvalidSocketException If socket is valid
+ * @return $lastSocketErrorMessage Last socket error message
+ * @throws InvalidSocketException If stored socket is invalid
*/
- function enableSocketNonBlocking ();
+ function getLastSocketErrorMessage ();
/**
* Handles socket error for given socket resource and peer data. This method
*/
function handleSocketError ($method, $line, array $socketData);
+ /**
+ * Translates socket error codes into our own internal names which can be
+ * used for call-backs.
+ *
+ * @param $errorCode The error code from socket_last_error() to be translated
+ * @return $errorName The translated name (all lower-case, with underlines)
+ */
+ function translateSocketErrorCodeToName ($errorCode);
+
}
-Subproject commit 8d7422139a55477388fcd6a30a1ce41d83780e5e
+Subproject commit 6751244349667c1165f05a319f3d66d3f6781b40