AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
# swoole_server->connection_info swoole_server->connection_info 函数用来获取连接的信息 > 需要swoole-1.5.8以上版本 connect_time, last_time 在v1.6.10+可用 connection_info可用于UDP服务器,但需要传入from_id参数 - 如果传入的fd存在,将会返回一个数组 - 连接不存在或已关闭,返回false ~~~ $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); ~~~ - **from_id** 来自哪个reactor线程 - **server_fd** 来自哪个server socket 这里不是客户端连接的fd - **server_port** 来自哪个Server端口 - **remote_port** 客户端连接的端口 - **remote_ip** 客户端连接的ip - **connect_time** 连接到Server的时间,单位秒 - **last_time** 最后一次发送数据的时间,单位秒 |  Swoole流程 | |-----| ![](https://box.kancloud.cn/2015-07-20_55aca2b250bc6.)