Workerman使用UDP协议,怎样获取客户端IP

木衣

不使用Nginx和Apache的情况下

2655 2 0
2个回答

keytehu

难道不是 $connection->getRemoteIp(); ?

  • 暂无评论
taozywu

@木衣
 
看文档+代码
 
/Workerman/Connection/UdpConnection.php L79左右有的。

/**
 75      * Get remote IP.
 76      *
 77      * @return string
 78      */
 79     public function getRemoteIp()
 80     {
 81         $pos = strrpos($this->_remoteAddress, ':');
 82         if ($pos) {
 83             return trim(substr($this->_remoteAddress, 0, $pos), '[]');
 84         }
 85         return '';
 86     }
  • 暂无评论
年代过于久远,无法发表回答
🔝