public function listen(string $ip, int $port)
    {
        $flags = STREAM_SERVER_BIND;
        if ($this->options['transport'] !== 'udp') {
            $flags |= STREAM_SERVER_LISTEN;
        }
        $this->socket = @\stream_socket_server(
            $this->options['transport'].'://'.$ip.':'.$port,
            $this->errorNumber,
            $this->errorMessage,
            $flags,
            $this->createSocketContext()
        );
        if (!$this->socket) {
            throw new ConnectionException(sprintf(
                'Unable to open %s socket (%s): %s',
                \strtoupper($this->options['transport']),
                $this->errorNumber,
                $this->errorMessage
            ));
        }

        return $this;
    }