编程语言
首页 > 编程语言> > php应用容器workerman_TcpConnection类getRemotePort接口说明及范例

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

作者:互联网

getRemotePort接口说明

int Connection::getRemotePort()

获得该连接的客户端端口。

getRemotePort接口范例

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

标签:TcpConnection,Worker,worker,接口,workerman,connection,getRemotePort
来源: https://blog.csdn.net/weixin_44039407/article/details/122074159