1--TEST-- 2swoole_socket_coro: writeVector_ssl eagain 3--SKIPIF-- 4<?php require __DIR__ . '/../include/skipif.inc'; ?> 5--FILE-- 6<?php 7require __DIR__ . '/../include/bootstrap.php'; 8 9use Swoole\Coroutine; 10use Swoole\Coroutine\Socket; 11use Swoole\Server; 12 13use function Swoole\Coroutine\run; 14 15$totalLength = 0; 16$iovector = []; 17$packedStr = ''; 18 19 20for ($i = 0; $i < 10; $i++) { 21 $iovector[$i] = str_repeat(get_safe_random(1024), 128); 22 $totalLength += strlen($iovector[$i]); 23 $packedStr .= $iovector[$i]; 24} 25$totalLength2 = rand(strlen($packedStr) / 2, strlen($packedStr) - 1024 * 128); 26 27$pm = new ProcessManager; 28$pm->parentFunc = function ($pid) use ($pm) { 29 run(function () use ($pm) { 30 global $totalLength, $iovector; 31 $conn = new Socket(AF_INET, SOCK_STREAM, IPPROTO_IP); 32 $conn->setProtocol([ 33 'open_ssl' => true, 34 ]); 35 $conn->connect('127.0.0.1', $pm->getFreePort()); 36 37 $ret = $conn->writeVectorAll($iovector); 38 Assert::eq($ret, $totalLength); 39 $conn->recv(); 40 echo "DONE\n"; 41 }); 42}; 43 44$pm->childFunc = function () use ($pm) { 45 run(function () use ($pm) { 46 global $totalLength, $packedStr; 47 $socket = new Socket(AF_INET, SOCK_STREAM, IPPROTO_IP); 48 $socket->setProtocol([ 49 'open_ssl' => true, 50 'ssl_cert_file' => SSL_FILE_DIR . '/server.crt', 51 'ssl_key_file' => SSL_FILE_DIR . '/server.key', 52 ]); 53 Assert::assert($socket->bind('127.0.0.1', $pm->getFreePort())); 54 Assert::assert($socket->listen(MAX_CONCURRENCY)); 55 56 /** @var Socket */ 57 $conn = $socket->accept(); 58 $conn->sslHandshake(); 59 60 Coroutine::sleep(0.5); 61 62 Assert::eq($conn->recvAll($totalLength), $packedStr, -1); 63 $conn->send('close'); 64 }); 65}; 66$pm->childFirst(); 67$pm->run(); 68?> 69--EXPECT-- 70DONE 71