Client Socket Info

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I want to retrive information from a System.Net.Sockets.Socket object
client, like the ip address or the name of the client; how can I do that???
thanks.
 
Socket s; //already connected

// Using the RemoteEndPoint property.
Console.WriteLine ("I am connected to " +
IPAddress.Parse(((IPEndPoint)s.RemoteEndPoint).Address.ToString ()) +
"on port number " + ((IPEndPoint)s.RemoteEndPoint).Port.ToString ()
);

// Using the LocalEndPoint property.
Console.WriteLine ("My local IpAddress is :" +
IPAddress.Parse (((IPEndPoint)s.LocalEndPoint).Address.ToString ()) +
"I am connected on port number " +
((IPEndPoint)s.LocalEndPoint).Port.ToString ()
);

to resolve the name of the client you can use Dns.Resolve for the obtained
ip address
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top