-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathselect_null.phpt
52 lines (47 loc) · 1.19 KB
/
select_null.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
--TEST--
swoole_client_sync: select
--SKIPIF--
<?php require __DIR__ . '/../include/skipif.inc'; ?>
--FILE--
<?php
require __DIR__ . '/../include/bootstrap.php';
use Swoole\Client;
use Swoole\Server;
use SwooleTest\ProcessManager;
const TIMEOUT = 0.05;
$pm = new ProcessManager;
$pm->parentFunc = function ($pid) use ($pm)
{
$client = new Client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_SYNC);
if (!$client->connect(TCP_SERVER_HOST, $pm->getFreePort(), -1))
{
exit("connect failed. Error: {$client->errCode}\n");
}
$r = [$client];
$w = $e = null;
$client->send("hello world\n");
swoole_select($r, $w, $e);
echo $client->recv();
$client->close();
$pm->kill();
};
$pm->childFunc = function () use ($pm)
{
$serv = new Server(TCP_SERVER_HOST, $pm->getFreePort(), SWOOLE_BASE, SWOOLE_SOCK_TCP);
$serv->set([
"worker_num" => 1,
'log_file' => '/dev/null',
]);
$serv->on("WorkerStart", function (Server $serv) use ($pm) {
$pm->wakeup();
});
$serv->on("Receive", function (Server $serv, $fd, $rid, $data) {
$serv->send($fd, "hello world\n");
});
$serv->start();
};
$pm->childFirst();
$pm->run();
?>
--EXPECT--
hello world