stream_socket_server

Supported Versions: PHP 5, PHP 7, PHP 8
Create an Internet or Unix domain server socket
<?php stream_socket_server(    string $address,    int &$error_code = null,    string &$error_message = null,    int $flags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN,    ?resource $context = null): resource|false
<?php $server = stream_socket_server('tcp://127.0.0.1:8080');

if (!$server) {

    exit(1);

}
<?php     public function testAddWriteStreamTriggersWhenSocketConnectionSucceeds()

    {

        $server = stream_socket_server('127.0.0.1:0');



        $errno = $errstr = null;

        $connecting = stream_socket_client(stream_socket_get_name($server, false), $errno, $errstr, 0, STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT);