Swoole\Coroutine\Server->set

Declaration

<?php
Swoole\Coroutine\Server->set(array $options): void

Parameters

options

A key-value associative array of server options.

Return

None


Description

Set the server options for the coroutine server.

Options must be set before the server is started.


Example

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',
]);

...