Home > PHP Framework > Swoole > Is swoole open source?

Is swoole open source?

(*-*)浩
Release: 2019-12-07 10:18:45
Original
2171 people have browsed it

Is swoole open source?

swoole is an extension running under PHP, which is actually different from ordinary extensions. Ordinary extensions just provide a library function. The swoole extension will take over control of PHP and enter the event loop after running. When an IO event occurs, swoole will automatically call back the specified PHP function. (Recommended learning: swoole video tutorial)

PHP’s asynchronous, parallel, high-performance network communication engine, written in pure C language, provides an asynchronous multi-threaded server in PHP language, asynchronous TCP /UDP network client, asynchronous MySQL, asynchronous Redis, database connection pool, AsyncTask, message queue, millisecond timer, asynchronous file reading and writing, asynchronous DNS query.

Swoole has built-in Http/WebSocket server/client and Http2.0 server.

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.

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

Multiple processes/multithreads

Multiple processes use the fork() system call

Multiple threads use pthread thread library

EventFd

Swoole uses eventfd as a mechanism for thread/inter-process message notification.

Timerfd

Swoole uses timerfd to implement the timer

SIgnalfd

signalfd is used in swoole To achieve signal shielding and processing. It can effectively avoid the problem of threads/processes being interrupted by signals and the system calling restart. The reactor thread will not receive any signals in the main process.

1.8.7或更高版本已完全兼容PHP7
Copy after login

The above is the detailed content of Is swoole open source?. For more information, please follow other related articles on the PHP Chinese website!

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