如何获取客户端的IP/Port?

aliu

walkor@qq答复:

在worker里面添加代码:

$address = $this->getRemoteAddress();

Gateway模型 Event.php 里面调用
$_SERVER
$_SERVER

4566 1 0
1个回答

walkor

正确

如果是在继承了Man\Core\SocketWorker的worker类里面(例如BusinessWorker.php Gateway.php等)使用
$this->getRemoteAddress();

如果是gateway模型,在Event.php中直接使用
$_SERVER
$_SERVER

  • 暂无评论
年代过于久远,无法发表回答
🔝