Socks5 上的 SSLStream 到 IMAP。无法写入流

SSLStream over Socks5 to IMAP. Cant write to Stream

我正在尝试连接到Socks5 Server,告诉他连接到IMAP Server 并获取一个Socket。我想使用 Socket 登录 IMAP。 我的问题是,在使用 SSL 流连接到 IMAP 后,我只能从流中读取。发送登录数据后,IMAP 服务器没有任何响应。

这就是我的代码:

public static void Main(string[] args)
    {               
        Console.WriteLine("Working *");

        var socksClient = new TcpClient();
        socksClient.Connect("127.0.0.1", 1080);

        var bw = new BinaryWriter(socksClient.GetStream(), Encoding.Default, true);
        var br = new BinaryReader(socksClient.GetStream(), Encoding.Default, true);

        //Tell the Socks5 to Connect to the IMAP:

        //Get the IP of the IMAP
        var ip = Dns.GetHostAddresses("mx.freenet.de")[0];

        //Me: Hello

        bw.Write(new byte[] {0x05, 0x01, 0x00});

        //Server: Hello

        br.ReadBytes(2);

        //Me: Connect to the IMAP on port 993

        byte[] data =  {0x05, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, getPortBytes(993)[0], getPortBytes(993)[1]};

        //Fill the IP in the DATA

        for (int i = 0; i < 4; i++)
        {
            data[i + 4] = ip.GetAddressBytes()[i];
        }

        bw.Write(data);

        //Server: Connection rdy

        br.ReadBytes(10);

        //Close our old Binary Writer/Reader

        br.Close();
        br.Dispose();
        bw.Close();
        bw.Dispose();

        //Handle SSL Stream

        var ssl = new SslStream(socksClient.GetStream(), false);

        //Auth as client
        ssl.AuthenticateAsClient("mx.freenet.de", null, SslProtocols.Tls, false);

        //Create new Binary Reader/Writer for the SSLStream
        var sslBr = new BinaryReader(ssl, Encoding.Default, true);
        var sslBw = new BinaryWriter(ssl, Encoding.Default, true);

        //Print the IMAP`s Hello
        string line = "";
        while (true)
        {
            char c = sslBr.ReadChar();
            line += c;
            if (c == '\n')
            {
                Console.WriteLine(line);
                break;
            }
        }

        //Send login to IMAP

        sslBw.Write((". login fipso@freenet.de HIDDEN"));

        //Read response as bytes
        while (true)
        {
            Console.WriteLine(sslBr.ReadByte());
        }

        /*
            Server gives no response.
            Why ?
        */

    }

编辑: 当运行代码:

Working *
* OK IMAP ready.

所有 IMAP 命令必须以“\r\n”结尾。

您的命令似乎没有换行结束。