Home > PHP Framework > Workerman > How does worker open the port?

How does worker open the port?

藏色散人
Release: 2019-12-12 13:23:56
Original
3699 people have browsed it

How does worker open the port?

workerman如何开启端口?

为Flash开启843端口

Flash发起socket连接远程服务端时,首先会到对应服务端的843端口请求一个安全策略文件。否则Flash无法建立与服务端的连接。在Workerman中可以用如下方法开启一个843端口,返回安全策略文件。

<?php
use Workerman\Worker;
require_once __DIR__ . &#39;/Workerman/Autoloader.php&#39;;
$flash_policy = new Worker(&#39;tcp://0.0.0.0:843&#39;);
$flash_policy->onMessage = function($connection, $message)
{
    $connection->send(&#39;<?xml version="1.0"?><cross-domain-policy><site-control permitted-cross-domain-policies="all"/><allow-access-from domain="*" to-ports="*"/></cross-domain-policy>&#39;."\0");
};
if(!defined(&#39;GLOBAL_START&#39;))
{
    Worker::runAll();
}
Copy after login

其中xml的安全策略内容可以根据你的需要进行自定义设置。

推荐:workerman教程

The above is the detailed content of How does worker open the port?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template