You've already forked qlg.tsgz.moe
addons
app_download_files
extend
hyhproject
mobile
oss
static
thinkphp
upload
vendor
5ini99
composer
oss-sdk
swoole
.github
benchmark
examples
include
src
tests
include
swoole_async
swoole_atomic
swoole_buffer
swoole_channel
swoole_client_async
swoole_client_coro
swoole_client_sync
eof.phpt
eof_timeout.phpt
length_protocol.phpt
length_protocol_02.phpt
recv_timeout.phpt
sendfile.phpt
swoole_client_connect1-1.phpt
swoole_client_connect1-2.phpt
swoole_client_connect1-3.phpt
swoole_client_send_recv.phpt
swoole_client_sync_send_recv.phpt
udp_client_sendto.phpt
swoole_coroutine
swoole_coroutine_channel
swoole_coroutine_util
swoole_event
swoole_function
swoole_http2_client
swoole_http2_client_coro
swoole_http_cilent_coro
swoole_http_client
swoole_http_server
swoole_https_client
swoole_lock
swoole_memory_pool
swoole_mysql
swoole_mysql_coro
swoole_process
swoole_redis
swoole_redis_coro
swoole_redis_server
swoole_serialize
swoole_server
swoole_server_port
swoole_socket_coro
swoole_table
swoole_timer
swoole_websocket_server
CONTRIBUTION
README.md
clean
coro_test.sh
new.sh
run-tests
start.sh
template.phpt
test-all-version.sh
test.sql
thirdparty
tools
travis
.gitignore
.gitmodules
.travis.yml
CMakeLists.txt
CREDITS
LICENSE
README.md
Version2.md
build.sh
clear.sh
config.m4
make.sh
package.xml
php7_wrapper.h
php_swoole.h
swoole.c
swoole_async.c
swoole_atomic.c
swoole_buffer.c
swoole_channel.c
swoole_channel_coro.cc
swoole_client.c
swoole_client_coro.c
swoole_config.h
swoole_coroutine.cc
swoole_coroutine.h
swoole_coroutine_util.c
swoole_event.c
swoole_http.h
swoole_http_client.c
swoole_http_client.h
swoole_http_client_coro.c
swoole_http_server.c
swoole_http_v2_client.c
swoole_http_v2_client.h
swoole_http_v2_client_coro.c
swoole_http_v2_server.c
swoole_lock.c
swoole_memory_pool.c
swoole_mmap.c
swoole_msgqueue.c
swoole_mysql.c
swoole_mysql.h
swoole_mysql_coro.c
swoole_postgresql_coro.c
swoole_postgresql_coro.h
swoole_process.c
swoole_process_pool.c
swoole_redis.c
swoole_redis_coro.c
swoole_redis_server.c
swoole_ringqueue.c
swoole_runtime.cc
swoole_serialize.c
swoole_serialize.h
swoole_server.c
swoole_server_port.c
swoole_socket_coro.c
swoole_table.c
swoole_timer.c
swoole_trace.c
swoole_websocket_server.c
wechat
.htaccess
autoload.php
wxtmp
.gitignore
.htaccess
.user.ini
404.html
H5B854518.wgt
admin.php
app-release.apk
app_download.html
cash.lock
demo.php
get_startup.php
get_version.php
get_version_new.php
index.html
index.php
reg.lock
robots.txt
109 lines
2.7 KiB
PHP
Executable File
109 lines
2.7 KiB
PHP
Executable File
--TEST--
|
|
swoole_client: eof protocol [sync]
|
|
--SKIPIF--
|
|
<?php require __DIR__ . '/../include/skipif.inc'; ?>
|
|
--INI--
|
|
assert.active=1
|
|
assert.warning=1
|
|
assert.bail=0
|
|
assert.quiet_eval=0
|
|
|
|
|
|
--FILE--
|
|
<?php
|
|
require_once __DIR__ . '/../include/bootstrap.php';
|
|
require_once __DIR__ . '/../include/swoole.inc';
|
|
|
|
$pm = new ProcessManager;
|
|
$port = get_one_free_port();
|
|
$pm->parentFunc = function ($pid) use ($port)
|
|
{
|
|
$client = new swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_SYNC);
|
|
$client->set(['open_eof_check' => true, "package_eof" => "\r\n\r\n"]);
|
|
if (!$client->connect('127.0.0.1', $port, 5, 0))
|
|
{
|
|
echo "Over flow. errno=" . $client->errCode;
|
|
die("\n");
|
|
}
|
|
|
|
$client->send("recv\r\n\r\n");
|
|
|
|
//小包
|
|
for ($i = 0; $i < 1000; $i++)
|
|
{
|
|
$pkg = $client->recv();
|
|
assert($pkg and strlen($pkg) <= 2048);
|
|
}
|
|
echo "SUCCESS\n";
|
|
//慢速发送
|
|
for ($i = 0; $i < 100; $i++)
|
|
{
|
|
$pkg = $client->recv();
|
|
assert($pkg and strlen($pkg) <= 8192);
|
|
}
|
|
echo "SUCCESS\n";
|
|
//大包
|
|
for ($i = 0; $i < 1000; $i++)
|
|
{
|
|
$pkg = $client->recv();
|
|
assert($pkg != false);
|
|
$_pkg = unserialize($pkg);
|
|
assert(is_array($_pkg));
|
|
assert($_pkg['i'] == $i);
|
|
assert($_pkg['data'] <= 256 * 1024);
|
|
}
|
|
echo "SUCCESS\n";
|
|
$client->close();
|
|
|
|
swoole_process::kill($pid);
|
|
};
|
|
|
|
$pm->childFunc = function () use ($pm, $port)
|
|
{
|
|
$serv = new swoole_server("127.0.0.1", $port, SWOOLE_BASE);
|
|
$serv->set(array(
|
|
'package_eof' => "\r\n\r\n",
|
|
'open_eof_check' => true,
|
|
'open_eof_split' => true,
|
|
'dispatch_mode' => 3,
|
|
'package_max_length' => 1024 * 1024 * 2, //2M
|
|
'socket_buffer_size' => 256 * 1024 * 1024,
|
|
'send_yield' => true,
|
|
"worker_num" => 1,
|
|
'log_file' => '/tmp/swoole.log',
|
|
));
|
|
$serv->on("WorkerStart", function (\swoole_server $serv) use ($pm)
|
|
{
|
|
$pm->wakeup();
|
|
});
|
|
$serv->on('receive', function (swoole_server $serv, $fd, $rid, $data)
|
|
{
|
|
//小包
|
|
for ($i = 0; $i < 1000; $i++)
|
|
{
|
|
$serv->send($fd, str_repeat('A', rand(100, 2000)) . "\r\n\r\n");
|
|
}
|
|
//慢速发送
|
|
for ($i = 0; $i < 100; $i++)
|
|
{
|
|
$serv->send($fd, str_repeat('A', rand(1000, 2000)));
|
|
usleep(rand(10000, 50000));
|
|
$serv->send($fd, str_repeat('A', rand(2000, 4000)) . "\r\n\r\n");
|
|
}
|
|
//大包
|
|
for ($i = 0; $i < 1000; $i++)
|
|
{
|
|
$serv->send($fd, serialize(['i' => $i, 'data' => str_repeat('A', rand(20000, 256 * 1024))]) . "\r\n\r\n");
|
|
}
|
|
});
|
|
$serv->start();
|
|
};
|
|
|
|
$pm->childFirst();
|
|
$pm->run();
|
|
?>
|
|
--EXPECT--
|
|
SUCCESS
|
|
SUCCESS
|
|
SUCCESS
|