1--TEST-- 2swoole_socket_coro: readVector with ssl 3--SKIPIF-- 4<?php require __DIR__ . '/../include/skipif.inc'; ?> 5--FILE-- 6<?php 7require __DIR__ . '/../include/bootstrap.php'; 8 9use Swoole\Coroutine\Socket; 10use Swoole\Server; 11 12use function Swoole\Coroutine\run; 13 14$pm = new ProcessManager; 15$pm->parentFunc = function ($pid) use ($pm) { 16 run(function () use ($pm) { 17 $conn = new Socket(AF_INET, SOCK_STREAM, IPPROTO_IP); 18 19 $conn->setProtocol([ 20 'open_ssl' => true, 21 ]); 22 $conn->connect('127.0.0.1', $pm->getFreePort()); 23 24 $ret = $conn->send('helloworld'); 25 Assert::eq($ret, strlen('helloworld')); 26 $conn->recv(); 27 echo "DONE\n"; 28 }); 29}; 30 31$pm->childFunc = function () use ($pm) { 32 run(function () use ($pm) { 33 global $totalLength, $packedStr; 34 $socket = new Socket(AF_INET, SOCK_STREAM, IPPROTO_IP); 35 $socket->setProtocol([ 36 'open_ssl' => true, 37 'ssl_cert_file' => SSL_FILE_DIR . '/server.crt', 38 'ssl_key_file' => SSL_FILE_DIR . '/server.key', 39 ]); 40 Assert::assert($socket->bind('127.0.0.1', $pm->getFreePort())); 41 Assert::assert($socket->listen(MAX_CONCURRENCY)); 42 43 /** @var Socket */ 44 $conn = $socket->accept(); 45 $conn->sslHandshake(); 46 47 Assert::eq($conn->readVector([5, 5]), ['hello', 'world']); 48 $conn->send('close'); 49 }); 50}; 51$pm->childFirst(); 52$pm->run(); 53?> 54--EXPECT-- 55DONE 56