src/FreeDSx/Socket/SocketServer.php
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;
    }
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;
    }
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 ; }
Create the socket server and bind to a specific port to listen for clients.

@param string $ip
@param int $port
@return $this
@throws ConnectionException
@internal param string $ip
Create the socket server and bind to a specific port to listen for clients .