Creating a TCP Client Connection with SSL

后端 未结 2 825
小蘑菇
小蘑菇 2020-12-25 08:28

I\'m trying to create a TCP connection and send/read data that uses SSL, but I haven\'t been able to successfully accomplish this.

What I\'d like to do is something

相关标签:
2条回答
  • 2020-12-25 08:47

    BinaryReader reads primitive data types as binary values in a specific encoding, is that what your server sends?
    If not use StreamReader:

    TcpClient _tcpClient = new TcpClient("host", 110);
    
    StreamReader reader = 
       new StreamReader(new System.Net.Security.SslStream(_tcpClient.GetStream(), true));
    
    Console.WriteLine(reader.ReadToEnd());
    
    0 讨论(0)
  • 2020-12-25 08:50

    I'm not entirely sure if this will work for your application but I would recommend taking a look at stunnel:
    http://www.stunnel.org

    I've used it for wrapping existing TCP connections in the past.

    0 讨论(0)
提交回复
热议问题