发布于 2015-08-09 09:48:04 | 83 次阅读 | 评论: 0 | 来源: 网络整理
swoole_server->connection_info 函数用来获取连接的信息
function swoole_server->connection_info(int $fd, int $from_id, bool $ignore_close = false)
需要swoole-1.5.8以上版本
connect_time, last_time 在v1.6.10+可用
connection_info可用于UDP服务器,但需要传入from_id参数
$fdinfo = $serv->connection_info($fd);
var_dump($fdinfo);
array(5) {
["from_id"]=>
int(3)
["server_fd"]=>
int(14)
["server_port"]=>
int(9501)
["remote_port"]=>
int(19889)
["remote_ip"]=>
string(9) "127.0.0.1"
["connect_time"]=>
int(1390212495)
["last_time"]=>
int(1390212760)
}
$udp_client = $serv->connection_info($fd, $from_id);
var_dump($udp_client);