I have managed to get the connected clients IP with the code below but can’t seem to get the hostname.
Globals.connectedIPAddress = "" + IPAddress.Parse(((
IPEndPoint)_client.Client.RemoteEndPoint).Address.ToString());
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, not every IP address has a name. However, given the
IPAddressyou can useDns.GetHostEntryto try to resolve it. Also note that if it’s being a NAT router, you’ll be getting the router’s IP address rather than their actual machine.And just to address the point in the comments, I agree that there’s no point in ToString/Parse/ToString: