Swoole can be widely used in the Internet, mobile communications, enterprise software, online games, Internet of Things, Internet of Vehicles, smart homes and other fields. Using PHP Swoole as a network communication framework can greatly improve the efficiency of enterprise IT R&D teams and focus more on developing innovative products.
Swoole has a built-in asynchronous non-blocking, multi-threaded network IO server at the bottom. PHP programmers only need to handle event callbacks and do not need to care about the underlying layer.
Unlike fully asynchronous frameworks such as Nginx/Tornado/Node.js, Swoole supports both fully asynchronous and synchronous. (Recommended learning: swoole video tutorial)
Swoole is open source and free software, and the licensing agreement is Apache2.0. Both corporate and individual developers can use Swoole's code for free, and modifications made on Swoole can be used in commercial products without open source (note: the copyright statement of the original author must be retained).
Implementation of Swoole
Swoole is written in pure C and does not rely on other third-party libraries.
swoole does not use libevent, so there is no need to install libevent
swoole does not rely on PHP's stream/sockets/pcntl/posix/sysvmsg and other extensions
socket Part
swoole uses the underlying socket system call. See sys/socket.h
IO event loop
The event loop of the main process uses select/poll, because there are only a few file descriptors in the main thread, use Just select/poll
Use epoll/kqueue in the reactor thread/worker process
The task process does not have an event loop, and the process will cycle and block the read pipe
Many people use it strace -p to view the swoole main process can only see the poll system call. The correct way to view it is strace -f -p
The above is the detailed content of What is swoole used for?. For more information, please follow other related articles on the PHP Chinese website!