facebook / facebook/hhvm

socket_read() doesn't work using the PHP_NORMAL_READ option

Open
#4,799 1 comment 0 reactions 0 assignees View on GitHub
php5 incompatibility
Dominant language
C++
Stars
18.7k
Forks
3.1k
Avg merge
1h 47m
Merged PRs (30d)
2

Description

The socket_read() generates the following error when used with the PHP_NORMAL_READ option:
`Warning: unable to read from socket [2]: No such file or directory in some/path/server.php line 45`

Script used:

``` php
$client) {
if (in_array($client, $read)) {
if (($buffer = socket_read($client, 1024, PHP_NORMAL_READ)) === false) {
unset($clients[$key]);
echo socket_strerror(socket_last_error($client)) . "\n";
}
var_dump($buffer);
}
}
} while (true);

socket_close($sock);
?>
```

You can reproduce the bug by executing the following commands in two different terminals.
Terminal 1:
php server.php

Terminal 2:
nc localhost 10000

Result:

```
Warning: unable to read from socket [2]: No such file or directory in some/path/server.php line 45
No such file or directory
bool(false)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.