May 14, 2021 Swoole
Swoole is an extesion extension running under PHP, which is
actually different from a normal extension. A
normal extension simply provides a library function. T
he swoole extension, on the other hand, takes over control of PHP after it runs and enters the event loop. W
hen an IO event occurs, swoole automatically calls back to the specified PHP function.
PHP's asynchronous, parallel, high-performance network communication engine, written in pure C language, provides PHP-language asynchronous multithreaded servers, asynchronous TCP/UDP network clients, asynchronous MySQL, asynchronous Redis, database connection pools, AsyncTask, message queues, millisecond timers, asynchronous file read and write, asynchronous DNS queries. Swoole has built-in Http/WebSocket server/client, Http2.0 server side.
Swoole can be widely used in the Internet, mobile communications, enterprise software, online games, Internet of Things, car networking, smart home and other fields. Using PHP-Swoole as a network communications framework can greatly improve the efficiency of enterprise IT research and development teams and focus more on developing innovative products.
The Swoole underlying has an asynchronous non-blocking, multithreaded network IO server built in. P HP programmers only need to handle event callbacks without having to care about the underlying. Unlike all asynchronous frameworks such .js Nginx / Tornado / Node, Swoole supports both full asynchronous and synchronization.
Swoole is open source free software and the license agreement is Apache 2.0. Both business and individual developers can use Swoole's code for free, and changes made on top of Swoole can be used for commercial products without the need for open source (Note: the original author's copyright notice must be retained).
Swoole is written in pure C and does not rely on other third-party libraries.
Swoole uses the underlying socket system call. See sys/socket.h
There are a lot of people who use tracke-p to see that the main swoole process can only see the poll system call. The correct way to view this is trace -f -p
Swoole uses eventfd as a mechanism for thread/inter-process message notification.
Swoole uses timerfd to implement the timer
swoole uses signalfd to shield and process signals. Y ou can effectively avoid the problem of threads/processes being interrupted by signals and the system calling restart. The actor thread does not accept any signals in the main process.
1.8.7 or later is fully compatible with PHP7