src/Datagram/DefaultDatagramFactory.php
public function create(string $host, int $port = null, array $options = []): Datagram
    {
        $autoClose = (bool) ($options['auto_close'] ?? true);

        $context = [];
        
        $context['socket'] = [];
        $context['socket']['bindto'] = Socket\makeName($host, $port);
        
        $context = stream_context_create($context);
        
        $uri = Socket\makeUri('udp', $host, $port);
        // Error reporting suppressed since stream_socket_server() emits an E_WARNING on failure (checked below).
        $socket = @stream_socket_server($uri, $errno, $errstr, STREAM_SERVER_BIND, $context);
        
        if (!$socket || $errno) {
            throw new FailureException(
                sprintf('Could not create datagram on %s: Errno: %d; %s', $uri, $errno, $errstr)
            );
        }
        
        return new BasicDatagram($socket, $autoClose);
    }
public function create(string $host, int $port = null, array $options = []): Datagram
    {
        $autoClose = (bool) ($options['auto_close'] ?? true);

        $context = [];
        
        $context['socket'] = [];
        $context['socket']['bindto'] = Socket\makeName($host, $port);
        
        $context = stream_context_create($context);
        
        $uri = Socket\makeUri('udp', $host, $port);
        // Error reporting suppressed since stream_socket_server() emits an E_WARNING on failure (checked below).
        $socket = @stream_socket_server($uri, $errno, $errstr, STREAM_SERVER_BIND, $context);
        
        if (!$socket || $errno) {
            throw new FailureException(
                sprintf('Could not create datagram on %s: Errno: %d; %s', $uri, $errno, $errstr)
            );
        }
        
        return new BasicDatagram($socket, $autoClose);
    }
{@inheritdoc}