OpenSwoole\Coroutine\Server::__construct

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Declaration

<?php OpenSwoole\Coroutine\Server::__construct(string $host, int $port = 0, bool $ssl = false, bool $reusePort = false): OpenSwoole\Coroutine\Server

Parameters

host

The host/IP to listen on when the server is started. Check the description for host types.

port

The port number to listen on.

ssl

If SSL should be enabled or not.

reusePort

If port reuse should be enabled or not. Allows servers or other processes to use the same port, requires a Linux Kernel which is at least version 3.8.0 or higher.

Return

Returns a new OpenSwoole\Coroutine\Server object or throws an exception if something is wrong.


Description

The OpenSwoole coroutine server class constructor. Create a new TCP coroutine focused server.

If the server fails to bind the host and port given, it will fail to be created and it will throw a OpenSwoole\Exception which you can then use to see what went wrong and handle any errors.

Host Types

  • IPv4: 127.0.0.1
  • IPv6: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
  • Unix Socket: unix:/tmp/test.sock

Last updated on September 1, 2022