workerman如何开启端口?
为Flash开启843端口
Flash发起socket连接远程服务端时,首先会到对应服务端的843端口请求一个安全策略文件。否则Flash无法建立与服务端的连接。在Workerman中可以用如下方法开启一个843端口,返回安全策略文件。
<?php use Workerman\Worker; require_once __DIR__ . '/Workerman/Autoloader.php'; $flash_policy = new Worker('tcp://0.0.0.0:843'); $flash_policy->onMessage = function($connection, $message) { $connection->send('<?xml version="1.0"?><cross-domain-policy><site-control permitted-cross-domain-policies="all"/><allow-access-from domain="*" to-ports="*"/></cross-domain-policy>'."\0"); }; if(!defined('GLOBAL_START')) { Worker::runAll(); }
其中xml的安全策略内容可以根据你的需要进行自定义设置。
推荐:workerman教程
以上就是workerman如何开启端口的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号