Skip to content

Commit

Permalink
SocketLoader: safer check for timeout?
Browse files Browse the repository at this point in the history
  • Loading branch information
kornrunner authored and io-developer committed Jul 12, 2021
1 parent f945d7c commit 9f93d37
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Iodev/Whois/Loaders/SocketLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ public function loadText($whoisHost, $query)
if (!$handle) {
throw new ConnectionException($errstr, $errno);
}

stream_set_timeout($handle, $this->timeout);

if (false === fwrite($handle, $query)) {
throw new ConnectionException("Query cannot be written");
}
$text = "";
while (!feof($handle)) {
$chunk = fread($handle, 8192);
if (false === $chunk || $chunk === '') {
if (false === $chunk || stream_get_meta_data($handle)['timed_out']) {
throw new ConnectionException("Response chunk cannot be read");
}
$text .= $chunk;
Expand Down

0 comments on commit 9f93d37

Please sign in to comment.