public function listen() 
    {        
        $context = stream_context_create(['socket' => $this->options]);        
        if($this->getOption('SO_REUSEPORT')) {
            stream_context_set_option($context, 'socket', 'so_reuseport', 1);
        }
        
        $flag = $this->isUDP() ? STREAM_SERVER_BIND : STREAM_SERVER_BIND | STREAM_SERVER_LISTEN;
        
        if($this->is_ssl ){
            foreach($this->ssl as $name => $value){
                if($value === null) continue;
                stream_context_set_option($context, 'ssl', $name, $value);
            }
        }
        
        $errno = $errmsg = null;
        
        $this->socket = @stream_socket_server($this->socket_name, $errno, $errmsg, $flag, $context);
        if(!$this->socket || $errno) {
            $this->socket = null;
            Yii::error("$this->listen $errmsg");
            return false;
        }
        
        /**
        When you create the binding for stream_socket_server(), make sure that you choose the tcp:// wrapper. 
        DO NOT USE ssl:// or tls://. Anything other than tcp:// will not work correctly AS A SERVER, 
        those transports are what you use when making connections with PHP as a client.
         
        Remember that the encryption does not start until after an SSL handshake completed, 
        so the server has to listen in non-encrypted mode for new connections, 
        and encryption doesn't start until certs are exchanged and a cipher is selected. 
        When a new connection arrives you accept it with stream_socket_accept() and then use stream_socket_enable_crypto() to start the SSL session.        
         */
        
        if($this->is_ssl){
            stream_socket_enable_crypto($this->socket, false);            
        }
        
        if($this->isUnix()){
            list(,$sockfile) = explode('://', $this->socket_name, 2);
            $sockfile = realpath($sockfile);
            $this->socket_name = $this->transport.'://'.$sockfile;
            chmod($sockfile, 0777);
        }
        
        if (function_exists('socket_import_stream') && $this->transport === 'tcp' ) {
            $socket = socket_import_stream($this->socket);
            foreach($this->options as $name => $value) {
                if($value === null || !defined($name)) continue;
                socket_set_option($socket, SOL_SOCKET, constant($name), $value);
            }
           
            socket_set_option($socket, SOL_TCP, TCP_NODELAY, 1);
        }
        
        stream_set_blocking($this->socket, 0);
        
        stream_socket_enable_crypto($this->socket, false);
        
        Yii::debug("$this->listen listened", 'beyod');
        
        return $this;
    }