0

I have a small home server (Ubuntu+XAMPP) and 2 PHP scripts: server.php and client.php, which both communicate to each other via sockets.

When I run server.php / client.php on the same machine (localhost), it works fine. Also, when I run server.php on the server, and client.php on the same server but from other local PC (i.e. local_server_ip/client.php), all works fine as well.

However, when I run server.php on the server and client.php on the other PC on the same network (replacing localhost with local_server_ip_addr in the client.php script), it fails with the actively refused connection error.

All necessary ports are forwarded in the router. I guess it is kind of security block on XAMPP/Linux and can be eliminated by some configuration file. I replaced Deny from all in the New XAMPP security concept with Allow from all in httpd-xamp.conf file, but it still fails.

Any help would be much appreciated.

(PS: server/client scripts examples taken from http://i-novice.net/sokety-v-php/ )

UPD: Have modified port 8080 (the one is dedicated for sockets in my system) to XXXXX. All works fine!

4

1 回答 1

0

如果这种情况可靠地发生,它实际上意味着机器存在,但是它没有在预定端口上侦听的管理员,或者有防火墙阻止你。

如果它定期发生 - 您“不时地”使用 - 并且重试成功,则很可能是因为服务器具有完全的“过剩”。

当您在聆听附件上坚持要得到承认时,您就会陷入困境。这种过剩是有限的,而且很短 - 1、2 或 3 的估计并不奇怪 - 因此操作系统可能无法满足您对“确认”的请求。

构建是监听能力的一个参数 - 所有方言和阶段都以这种方式具有基本相同的 API,即使是 C# 也是如此。如果您控制服务器,则此参数通常是可配置的,并且可能从一些设置文档或注册表中读取。研究如何安排您的服务器。

如果您编写了服务器,您可能会在确认您的附件时进行大量准备,这可以更好地转移到不同的专家字符串,以便您的确认随时准备获得关联。您可以研究不同的结构工程决策,以减轻排队和依次处理客户的麻烦。

尽管您是否可以构建服务器构建,但您确实需要在客户代码中重试基本原理以适应此问题 - 因为即使构建时间很长,服务器也可能会在那时对该端口产生大量不同的需求。

如果用于映射的端口耗尽,NAT 交换机极有可能出现这种错误。我认为我们可以把这个概率作为一个很长的镜头,但是,因为交换机在厌倦之前有 64K 并发关联与相同的目标位置/端口。

于 2015-05-20T07:12:37.277 回答