Skip to content

Commit 73f37ca

Browse files
Merge pull request #62 from jonathan-rowley/create_timeout_error
Adding a error message for timeout events
2 parents 700a0bb + 0f49445 commit 73f37ca

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/connection/StreamSocket.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ public function write(string $buffer)
9898
public function read(int $length = 2048): string
9999
{
100100
$res = stream_get_contents($this->stream, $length);
101+
102+
if (stream_get_meta_data($this->stream)["timed_out"])
103+
throw new ConnectException('Connection timeout reached after '.$this->timeout.' seconds.');
104+
101105
if (empty($res))
102106
throw new ConnectException('Read error');
103107

0 commit comments

Comments
 (0)