php应用容器workerman_TcpConnection类getRemoteIp接口说明及范例

getRemoteIp接口说明

string Connection::getRemoteIp()

获得该连接的客户端ip。

getRemoteIp接口范例

use Workerman\Worker;
use Workerman\Connection\TcpConnection;
require_once __DIR__ . '/vendor/autoload.php';

$worker = new Worker('websocket://0.0.0.0:8484');
$worker->onConnect = function(TcpConnection $connection)
{
    echo "new connection from ip " . $connection->getRemoteIp() . "\n";
};
// 运行worker
Worker::runAll();
上一篇:php应用容器workerman_TcpConnection类getRemotePort接口说明及范例


下一篇:nginx高性能原因