1 Star 0 Fork 345

Khail / swoole

forked from winting / swoole 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
client.php 657 Bytes
一键复制 编辑 原始数据 按行查看 历史
韩天峰 提交于 2013-11-05 09:47 . init
<?php
$clients = array();
for($i=0; $i< 2; $i++)
{
$client = new swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_SYNC); //同步阻塞
$ret = $client->connect('127.0.0.1', 9501, 0.5, 0);
if(!$ret)
{
echo "Connect Server fail.errCode=".$client->errCode;
}
else
{
$client->send("HELLO WORLD\n");
$clients[$client->sock] = $client;
}
}
while(!empty($clients))
{
$write = $error = array();
$read = array_values($clients);
$n = swoole_client_select($read, $write, $error, 0.6);
if($n > 0)
{
foreach($read as $index=>$c)
{
echo "Recv #{$c->sock}: ".$c->recv()."\n";
unset($clients[$c->sock]);
}
}
}
1
https://gitee.com/Khail/swoole.git
git@gitee.com:Khail/swoole.git
Khail
swoole
swoole
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891