How to get TCPClient's IP from TCPListener

  • Thread starter Thread starter zZ
  • Start date Start date
Z

zZ

Hi All,

I'm building a TCPListener as the server to accept TCPClient connections,
using

TCPListener.AcceptTcpClient.

I'd like to retrieve client's IP after connected, but found no way to do so.
Is there a walkaround? Thanks for any tip.


Kind regards,
Zen
 
TCPClient tc = TCPListener.AcceptTcpClient();
Socket s = tc.Client;
Console.WriteLine("I am connected to " +
IPAddress.Parse(((IPEndPoint)s.RemoteEndPoint).Address.ToString()) +
"on port number " + ((IPEndPoint)s.RemoteEndPoint).Port.ToString());


http://www.freesmtp.net

socket.RemoteEndPoint
 
Back
Top