Can PHP control communication with IoT devices through Socket?
高洛峰
高洛峰 2017-05-16 13:11:41
0
5
751

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.

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(5)
大家讲道理

Using swoole is very good
We have already used it on WeChat mini programs

阿神

The websocket in the php swoole extension can realize real-time communication function

过去多啦不再A梦

Preferred swoole

曾经蜡笔没有小新

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.

phpcn_u1582

workerman or swoole are both acceptable.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template