diff --git a/src/IO/StreamSocket.php b/src/IO/StreamSocket.php index 0f127fc..702a3e4 100644 --- a/src/IO/StreamSocket.php +++ b/src/IO/StreamSocket.php @@ -194,14 +194,20 @@ public function connect() $this->port ); - $this->sock = stream_socket_client( - $remote, - $errno, - $errstr, - $this->timeout, - STREAM_CLIENT_CONNECT, - $this->context - ); + try { + $this->sock = stream_socket_client( + $remote, + $errno, + $errstr, + $this->timeout, + STREAM_CLIENT_CONNECT, + $this->context + ); + } catch(\ErrorException $e) { + throw new IOException(sprintf( + 'Error to connect to the server(%s) : "%s"', $errno, $errstr + )); + } if (false === $this->sock) { throw new IOException(sprintf(