I am answering my own question.
Socket socketForClient =
tcpListener.AcceptSocket( );
if (socketForClient.Connected)
{
Console.WriteLine("{0}", socketForClient.RemoteEndPoint.ToString( ));
Console.WriteLine("Client connected");
}
That will print the IP address and port of the client connected on
socketForClient.
"Matt_is_a_novice" wrote:
I am writing a server to open a TCPListener, the client connects, and the
server returns a Socket. I want to know what IP address is connected to my
server. How do I retrieve the IP address of my client from the Socket?
Thanks.