Move address polling to a Job, better catch Socket connection refused errors

This commit is contained in:
Deon George
2021-09-20 20:39:03 +10:00
parent 8b8b513ed1
commit 82e3283d6d
4 changed files with 86 additions and 41 deletions

View File

@@ -241,7 +241,13 @@ final class SocketClient {
if ($socket === FALSE)
throw new SocketException(SocketException::CANT_CREATE_SOCKET,socket_strerror(socket_last_error($socket)));
$result = socket_connect($socket,$address,$port);
try {
$result = socket_connect($socket,$address,$port);
} catch (\ErrorException $e) {
throw new SocketException(SocketException::CANT_CONNECT,socket_strerror(socket_last_error($socket)));
}
if ($result === FALSE)
throw new SocketException(SocketException::CANT_CONNECT,socket_strerror(socket_last_error($socket)));