How to resolve the remote host name from IP address? [modified]
-
The function Socket.AcceptSocket() creates a new socket for a connection, I can get the remote host IP address from Socket.RemoteEndPoint. but I want to know the remote host name(computer name), can i resolve the name from an IP address? -- modified at 11:45 Tuesday 13th February, 2007
-
The function Socket.AcceptSocket() creates a new socket for a connection, I can get the remote host IP address from Socket.RemoteEndPoint. but I want to know the remote host name(computer name), can i resolve the name from an IP address? -- modified at 11:45 Tuesday 13th February, 2007
Hi, i didn't test this but found it by searching for the local PC name. System.Net.Dns.BeginResolve or System.Net.Dns.Resolve if you also write the server app. you can send it yourself by using this at server site. System.Windows.Forms.SystemInformation.ComputerName; or System.Net.Dns.GetHostName(); hope it helps. :) Greetz Kurt Okay i did a small test for you .. and seems to work (but depreceated). System.Net.IPHostEntry tmp = System.Net.Dns.Resolve(textBox1.Text); textBox2.Text = tmp.HostName; fill in IP address in textbox1.. greetz -- modified at 10:57 Tuesday 13th February, 2007
-
The function Socket.AcceptSocket() creates a new socket for a connection, I can get the remote host IP address from Socket.RemoteEndPoint. but I want to know the remote host name(computer name), can i resolve the name from an IP address? -- modified at 11:45 Tuesday 13th February, 2007
-
I think you should use
System.Net.Dns.GetHostByAddress(String address)
Regards, Wasif Ehsan.Yep. Also seems to work. VS2005 suggests System.Net.Dns.GetHostEntry() when compiling. so there are several ways... ;) greetz Kurt