After searching on the Internet, I saw that there are many Socket-related functions in PHP. The usage process is:
socket_create
socket_bind
socket_listen
socket_accept
socket_read
socket_write
socket_close
However, what I don’t understand the most is the socket_accept step. To be used via while (true) {} infinite loop.
Is it possible to execute PHP files only through the CLI command line?
In addition, it seems easier to receive and send information to the server on the client side, but how can the server receive and send information to the client at will? (Instead of just receiving and sending once in the loop statement and then closing the socket object like the online examples.
大家讲道理2017-05-16 13:13:41
Using swoole is very good
We have already used it on WeChat mini programs
阿神2017-05-16 13:13:41
The websocket in the php swoole extension can realize real-time communication function
曾经蜡笔没有小新2017-05-16 13:13:41
What is Workerman
Workerman is an open source high-performance PHP socket server framework developed purely in PHP. It is widely used in the development of mobile apps, mobile communications, WeChat applets, mobile game servers, online games, PHP chat rooms, hardware communications, smart homes, Internet of Vehicles, Internet of Things and other fields. Supports TCP long connections, supports Websocket, HTTP and other protocols, and supports custom protocols. It has many high-performance components such as asynchronous Mysql, asynchronous Redis, asynchronous Http, asynchronous message queue, etc.