Swoole-1.8.0 adds support for multi-port mixed protocols. Server can listen to multiple ports, and each port can be set with different protocol processing methods (set) and callback functions (on). SSL/TLS transport encryption can also be enabled only for specific ports. (Recommended Learning: SWOOLE Video Tutorial )
Unclicable SET method, set the monitor port of the protocol processing option, default to inherit the setting of the main server
## on method, sets the listening port of the callback function. The callback function of the main server is used by default. The object type returned by the listening port is swoole_server_portThe swoole_server_port object of the listening port can call the set and on methods. The usage method is exactly the same as swoole_serverThe listening port can only set a few specific options, and can only set event callback functions related to data sending and receivingThe callback functions of different listening ports are still the same Worker Executed in the process spaceThe main server is WebSocket or Http protocol. The newly monitored TCP port will inherit the protocol settings of the main server by default. The set method must be called separately to set the new protocol to enable the new protocolListen to the new port
$port1 = $server->listen("127.0.0.1", 9501, SWOOLE_SOCK_TCP); $port2 = $server->listen("127.0.0.1", 9502, SWOOLE_SOCK_UDP); $port3 = $server->listen("127.0.0.1", 9503, SWOOLE_SOCK_TCP | SWOOLE_SSL);
Set the network protocol
$port1->set([ 'open_length_check' => true, 'package_length_type' => 'N', 'package_length_offset' => 0, 'package_max_length' => 800000,] ); $port3->set([ 'open_eof_split' => true, 'package_eof' => "\r\n", 'ssl_cert_file' => 'ssl.cert', 'ssl_key_file' => 'ssl.key',] );
The above is the detailed content of Does swoole support multiple ports and different protocols?. For more information, please follow other related articles on the PHP Chinese website!

The article outlines ways to contribute to the Swoole project, including reporting bugs, submitting features, coding, and improving documentation. It discusses required skills and steps for beginners to start contributing, and how to find pressing is

Article discusses extending Swoole with custom modules, detailing steps, best practices, and troubleshooting. Main focus is enhancing functionality and integration.

The article discusses using Swoole's asynchronous I/O features in PHP for high-performance applications. It covers installation, server setup, and optimization strategies.Word count: 159

Article discusses configuring Swoole's process isolation, its benefits like improved stability and security, and troubleshooting methods.Character count: 159

Swoole's reactor model uses an event-driven, non-blocking I/O architecture to efficiently manage high-concurrency scenarios, optimizing performance through various techniques.(159 characters)

Article discusses troubleshooting, causes, monitoring, and prevention of connection issues in Swoole, a PHP framework.

The article discusses tools and best practices for monitoring and optimizing Swoole's performance, and troubleshooting methods for performance issues.

Abstract: The article discusses resolving memory leaks in Swoole applications through identification, isolation, and fixing, emphasizing common causes like improper resource management and unmanaged coroutines. Tools like Swoole Tracker and Valgrind


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor