getRemoteIp

说明:

  1. string Connection::getRemoteIp()

获得该连接的客户端ip

参数

无参数

范例

  1. use Workerman\Worker;
  2. require_once __DIR__ . '/Workerman/Autoloader.php';
  3. $worker = new Worker('websocket://0.0.0.0:8484');
  4. $worker->onConnect = function($connection)
  5. {
  6. echo "new connection from ip " . $connection->getRemoteIp() . "\n";
  7. };
  8. // 运行worker
  9. Worker::runAll();