|
-
Oct 21st, 2022, 12:32 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Can't get pinged IP, Its name
Hi, consider a tcp/ip network simple ping app. How can we get "EntryName" or maybe "HostName" (Not sure what's the differences) corresponding to that IP address and show it next to other parameters on a data grid view?
I came up with this code. IPs, estimated ping delay and being successful or their offline condition are totally alright. What is missing is SystemName (HostName/GuestName/ClientName/ServerName/EntryName whatever it is and you called it):
Code:
Dim PING As New Ping
Dim REPLY As PingReply
Try
For i = 0 To 255
For j = 100 To 255
REPLY = PING.Send("192.168." & i.ToString & "." & j.ToString, 1)
TextBox1.Text = "192.168." & i.ToString & "." & j.ToString
If REPLY.Status = IPStatus.Success Then
DataGridView1.Rows.Add("192.168." & i.ToString & "." & j.ToString, Dns.EndGetHostEntry(IPAddress.Parse(TextBox1.Text)).HostName, REPLY.RoundtripTime.ToString)
End If
Next
Next
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
TextBox1 is somewhere you put "Under scanning IP" in it.
However mentioned code leads to an exception instantly: Unable to cast object of type 'System.Net.IPAddress' to type 'System.IAsyncResult'
What can I do? What are my options? Any clues are welcome here... ♥ Pourkascheff/.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|