Home > Backend Development > PHP Tutorial > PHP listens to WebSocket, which can be accessed locally but not from the external network.

PHP listens to WebSocket, which can be accessed locally but not from the external network.

WBOY
Release: 2016-10-19 10:40:54
Original
2076 people have browsed it

Firewall status OK:
PHP listens to WebSocket, which can be accessed locally but not from the external network.
Listening port: 2015

PHP listens to WebSocket, which can be accessed locally but not from the external network.

<code class="php">   $this->socket = socket_create(AF_INET,SOCK_STREAM, SOL_TCP);
   socket_set_option($this->socket, SOL_SOCKET, SO_REUSEADDR,true);
   socket_bind($this->socket, 0 , $this->port);
   //监听端口
   socket_listen($this->socket);
   socket_getsockname($this->socket, $ip,$port);
   printf("Server Open %s:%d\n",$ip,$port);</code>
Copy after login
Copy after login

ws://127.0.0.1: 2015 and ws://192.168.1.101: 2015 can both be created.
Using external IP will cause the link to time out.

Reply content:

Firewall status OK:
PHP listens to WebSocket, which can be accessed locally but not from the external network.
Listening port: 2015

PHP listens to WebSocket, which can be accessed locally but not from the external network.

<code class="php">   $this->socket = socket_create(AF_INET,SOCK_STREAM, SOL_TCP);
   socket_set_option($this->socket, SOL_SOCKET, SO_REUSEADDR,true);
   socket_bind($this->socket, 0 , $this->port);
   //监听端口
   socket_listen($this->socket);
   socket_getsockname($this->socket, $ip,$port);
   printf("Server Open %s:%d\n",$ip,$port);</code>
Copy after login
Copy after login

ws://127.0.0.1: 2015 and ws://192.168.1.101: 2015 can both be created.
Using external IP will cause the link to time out.

Is this your own PC, or a cloud server?

Computers at work or home need to do port mapping on the router. Otherwise, when accessing the company’s external network IP, there are so many machines on the network, why should we connect to yours?

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