PHP教程

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();
这篇关于php应用容器workerman_TcpConnection类getRemotePort接口说明及范例的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!