Join 4,000+ others and never miss out on new tips, tutorials, and more.
4.x is outdated, please check the latest version 22.x
Latest version:
pecl install openswoole-22.1.2
<?php Swoole\Coroutine\Server->set(array $options): void
A key-value associative array of server options.
None
Set the server options for the coroutine server.
Options must be set before the server is started.
Length Agreement
<?php
$server = new Swoole\Coroutine\Server('127.0.0.1', 8080);
$server->set([
'open_length_check' => true,
'package_max_length' => 1024 * 1024,
'package_length_type' => 'N',
'package_length_offset' => 0,
'package_body_offset' => 4,
]);
...
SSL Certificates
<?php
$server = new Swoole\Coroutine\Server('127.0.0.1', 443, $ssl = true);
$server->set([
'ssl_cert_file' => dirname(__DIR__) . '/ssl/server.crt',
'ssl_key_file' => dirname(__DIR__) . '/ssl/server.key',
]);
...