getRemotePort

说明:

  1. int Connection::getRemotePort()

获得该连接的客户端端口

参数

无参数

范例

  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 address " .
  7. $connection->getRemoteIp() . ":". $connection->getRemotePort() ."\n";
  8. };
  9. // 运行worker
  10. Worker::runAll();