-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathgetsockname.phpt
43 lines (33 loc) · 1.02 KB
/
getsockname.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
--TEST--
swoole_client_async: Swoole\Async\Client getsockname
--SKIPIF--
<?php require __DIR__ . '/../include/skipif.inc'; ?>
--FILE--
<?php
require __DIR__ . '/../include/bootstrap.php';
$simple_tcp_server = __DIR__ . "/../include/api/swoole_server/simple_server.php";
start_server($simple_tcp_server, TCP_SERVER_HOST, TCP_SERVER_PORT);
$timer = suicide(5000);
$cli = new \Swoole\Async\Client(SWOOLE_SOCK_TCP);
$cli->on("connect", function (Swoole\Async\Client $cli) use ($timer) {
Assert::true($cli->isConnected());
$i = $cli->getsockname();
Assert::assert($i !== false);
Assert::same($i["host"], '127.0.0.1');
$cli->close();
Swoole\Timer::clear($timer);
});
$cli->on("receive", function (Swoole\Async\Client $cli, $data) {
});
$cli->on("error", function (Swoole\Async\Client $cli) {
echo "error";
});
$cli->on("close", function (Swoole\Async\Client $cli) {
echo "SUCCESS";
Swoole\Event::exit();
});
$cli->connect(TCP_SERVER_HOST, TCP_SERVER_PORT, 1);
Swoole\Event::wait();
?>
--EXPECT--
SUCCESS