-
Notifications
You must be signed in to change notification settings - Fork 119
/
bug_gh_49.phpt
65 lines (58 loc) · 1.22 KB
/
bug_gh_49.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
53
54
55
56
57
58
59
60
61
62
63
64
65
--TEST--
Test for Github issue #49
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php
$context = new ZMQContext (1, false);
$server = new ZMQSocket ($context, ZMQ::SOCKET_REP);
$server->bind ('inproc://test');
$client = new ZMQSocket ($context, ZMQ::SOCKET_REQ);
$client->connect ('inproc://test');
$poll = new ZMQPoll();
$poll->add ($server, ZMQ::POLL_IN);
$poll->add ($client, ZMQ::POLL_IN);
for ($i = 0; $i < 10; $i++)
{
$readable = array();
$writable = array();
if ($i % 2)
{
$server->send ($i);
}
else
{
$client->send ($i);
}
$event = $poll->poll ($readable, $writable);
if (!$event)
{
continue;
}
foreach ($readable as $socket)
{
$msg = $socket->recv();
if ($socket === $server)
{
echo 'client to server msg:' . $msg . PHP_EOL;
}
else
{
echo 'server to client msg:' . $msg . PHP_EOL;
}
}
}
?>
--EXPECT--
client to server msg:0
server to client msg:1
client to server msg:2
server to client msg:3
client to server msg:4
server to client msg:5
client to server msg:6
server to client msg:7
client to server msg:8
server to client msg:9