使用SSL创建TCP客户端连接

我正在尝试创建TCP连接并发送/读取使用SSL的数据,但我无法成功完成此操作。

我想做的是这样的:

TcpClient _tcpClient = new TcpClient("host", 110); BinaryReader reader = new BinaryReader(new System.Net.Security.SslStream(_tcpClient.GetStream(), true)); Console.WriteLine(reader.ReadString()); 

我虽然没有运气。 创建BinaryReader时抛出exception。

有谁知道这样做的一个简单例子? 我不想写这个服务器端,只是客户端。

BinaryReader将原始数据类型读取为特定编码中的二进制值,这是您的服务器发送的内容吗?
如果不使用StreamReader:

 TcpClient _tcpClient = new TcpClient("host", 110); StreamReader reader = new StreamReader(new System.Net.Security.SslStream(_tcpClient.GetStream(), true)); Console.WriteLine(reader.ReadToEnd()); 

我不完全确定这是否适用于您的应用程序,但我建议您查看stunnel:
http://www.stunnel.org

我过去用它来包装现有的TCP连接。