diff --git a/src/Connection.php b/src/Connection.php index 54ea89a..3d1cbd7 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -56,14 +56,10 @@ public function write(string $payload): self $except = null; - try { - $selectResult = socket_select($read, $write, $except, $this->timeoutSeconds, $this->timeoutMicroseconds); - } catch (ErrorException $e) { - if ($this->isInterruptionErrorException()) { - continue; - } - - throw $e; + $selectResult = @socket_select($read, $write, $except, $this->timeoutSeconds, $this->timeoutMicroseconds); + + if ($selectResult === false && socket_last_error() === SOCKET_EINTR) { + continue; } if ($selectResult === false) { @@ -99,14 +95,10 @@ public function read(): Generator $except = null; - try { - $selectResult = socket_select($read, $write, $except, $this->timeoutSeconds, $this->timeoutMicroseconds); - } catch (ErrorException $e) { - if ($this->isInterruptionErrorException()) { - continue; - } + $selectResult = @socket_select($read, $write, $except, $this->timeoutSeconds, $this->timeoutMicroseconds); - throw $e; + if ($selectResult === false && socket_last_error() === SOCKET_EINTR) { + continue; } if ($selectResult === false) { @@ -126,9 +118,4 @@ public function read(): Generator yield $outputFromSocket; } } - - private function isInterruptionErrorException(): bool - { - return 4 === socket_last_error(); - } }