From a9499e72d6afa881b4f791899070ce89f4c1209f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Tue, 13 Oct 2015 12:42:14 +0200 Subject: [PATCH] Close stream resource if connection fails --- src/TcpConnector.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/TcpConnector.php b/src/TcpConnector.php index ddd5bd3..62d4b5f 100644 --- a/src/TcpConnector.php +++ b/src/TcpConnector.php @@ -65,6 +65,8 @@ public function checkConnectedSocket($socket) // The following hack looks like the only way to // detect connection refused errors with PHP's stream sockets. if (false === stream_socket_get_name($socket, true)) { + fclose($socket); + return Promise\reject(new ConnectionException('Connection refused')); }