public function checkConnectResult($sock, $flag, $arg)
    {
        $this->connectComplete();
        $this->removeEventLooper();
        
        $sock = socket_import_stream($this->socket);
        $code = socket_get_option($sock, SOL_SOCKET, SO_ERROR);
        $errstr = socket_strerror($code);
        
        if($code) {
            Yii::warning($this->target ." connect failed($code), $errstr", 'beyod');
            $this->trigger(Server::ON_CONNECT_FAILED, new ErrorEvent(['code'=>$code, 'errstr'=>$errstr]));
            return ;
        }
        
        $this->status = static::STATUS_ESTABLISHED;
        $this->id = static::generateId();
        
        static::$count++;
        
        static::$connections[$this->id] = $this;
        
        $this->peer = stream_socket_get_name($this->socket, true);
        $this->local = stream_socket_get_name($this->socket, false);
        
        Yii::debug('connected to '.$this->target.', '.$this, 'beyod');
        
        $this->trigger(Server::ON_CONNECT, new IOEvent());
        
        Yii::$app->eventLooper->addFdEvent($this->socket, EventLooper::EV_READ, [$this, 'readBuffer']);
        
        $this->afterConnected();
    }