public function proxyWrite()
    {
        Client::debug('proxy writeState: ', $this->proxyState);
        if ($this->proxyState === 1) {
            $buf = isset(self::$_socks5['user']) ? "\x05\x01\x02" : "\x05\x01\x00";
            $this->proxyState++;
            return $this->write($buf);
        } elseif ($this->proxyState === 3) {
            if (!isset(self::$_socks5['user'])) {
                return false;
            }
            $buf = chr(0x01) . chr(strlen(self::$_socks5['user'])) . self::$_socks5['user']
                . chr(strlen(self::$_socks5['pass'])) . self::$_socks5['pass'];
            $this->proxyState++;
            return $this->write($buf);
        } elseif ($this->proxyState === 5) {
            $pa = parse_url($this->conn);
            $buf = "\x05\x01\x00\x01" . pack('Nn', ip2long($pa['host']), isset($pa['port']) ? $pa['port'] : 80);
            $this->proxyState++;
            return $this->write($buf);
        } else {
            return false;
        }
    }