* @param $socketResource A valid socket resource
* @throws SocketConnectionException The connection attempts fails with a time-out
*/
- private function socketErrorConnectionTimedOutHandler ($socketResource) {
+ protected function socketErrorConnectionTimedOutHandler ($socketResource) {
// Get socket error code for verification
$socketError = socket_last_error($socketResource);
// Is the socket resource valid?
if (!is_resource($socketResource)) {
- // Something bad happened
+ /*
+ * Something bad happened, calling handleSocketError() is not
+ * possible here because that method would throw an
+ * InvalidSocketException back.
+ */
throw new SocketCreationException(array($helperInstance, gettype($socketResource)), BaseListener::EXCEPTION_SOCKET_CREATION_FAILED);
} // END - if
throw new SocketOptionException(array($helperInstance, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
} // END - if
+ // Set socket in non-blocking mode
+ if (!socket_set_nonblock($socketResource)) {
+ // Handle this socket error with a faked recipientData array
+ $helperInstance->handleSocketError($socketResource, array('0.0.0.0', '0'));
+
+ // And throw again
+ throw new SocketOptionException(array($helperInstance, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
+ } // END - if
+
// Set the resource
$helperInstance->setSocketResource($socketResource);
*/
} // END - if
- // Set socket in non-blocking mode
- if (!socket_set_nonblock($socketResource)) {
- // Handle this socket error with a faked recipientData array
- $helperInstance->handleSocketError($socketResource, array('0.0.0.0', '0'));
-
- // And throw again
- throw new SocketOptionException(array($helperInstance, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
- } // END - if
-
// Connection is fully established here, so change the state
PeerStateFactory::createPeerStateInstanceByName('connected', $helperInstance);