-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathssl_recv_timeout.phpt
41 lines (38 loc) · 1.17 KB
/
ssl_recv_timeout.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
--TEST--
swoole_client_sync: ssl recv timeout
--SKIPIF--
<?php require __DIR__ . '/../include/skipif.inc'; ?>
--FILE--
<?php
require __DIR__ . '/../include/bootstrap.php';
$pm = new ProcessManager;
$pm->parentFunc = function () use ($pm) {
$cli = new Swoole\Client(SWOOLE_SOCK_TCP | SWOOLE_SSL, SWOOLE_SOCK_SYNC);
$r = $cli->connect('127.0.0.1', $pm->getFreePort(), 5);
Assert::assert($r);
$cli->send("hello world\n");
$time = time();
$data = $cli->recv(1024);
Assert::assert((time() - $time) < 2);
Assert::same($data, "Swoole hello world\n");
$pm->kill();
};
$pm->childFunc = function () use ($pm) {
$serv = new Swoole\Server('127.0.0.1', $pm->getFreePort(), SWOOLE_BASE, SWOOLE_SOCK_TCP | SWOOLE_SSL);
$serv->set([
'log_file' => '/dev/null',
'ssl_cert_file' => SSL_FILE_DIR.'/server.crt',
'ssl_key_file' => SSL_FILE_DIR.'/server.key',
]);
$serv->on("workerStart", function ($serv) use ($pm) {
$pm->wakeup();
});
$serv->on('receive', function (Swoole\Server $serv, $fd, $tid, $data) {
$serv->send($fd, "Swoole $data");
});
$serv->start();
};
$pm->childFirst();
$pm->run();
?>
--EXPECT--