I would like to get the portnumber from a sslstream in C#. When you have TcpClient you can extract this like:
TcpClient client = listener.AcceptTcpClient();
var endpoint = ((IPEndPoint)client.Client.RemoteEndPoint);
I would like to get the portnumber from a sslstream in C#. When you have TcpClient you can extract this like:
TcpClient client = listener.AcceptTcpClient();
var endpoint = ((IPEndPoint)client.Client.RemoteEndPoint);
SslStream
is a "decorator" around another arbitrary Stream
, in this case a NetworkStream
. It doesn't expose the inner (tail) stream (well, it does, but InnerStream
is protected
), and SslStream
itself has no concept of a port. Basically: you'll need to get this information separately to wrapping it in the decorator.