Avatar of zettler92656
zettler92656Flag for United States of America asked on

I want to ping a host in Visual Basic and get as a return the IP address

Hi,

I know how to operate My.Computer.Network.Ping("label-2304", 1000).

It will give me true or false as a return.

What I am looking for is to ping the host and get the IP address back in return.

I am trying to write an application which gives me a list of all the hosts on a peer to peer network with their IP address.

Any ideas?

Best regards

Max
Visual Basic.NETNetworking ProtocolsWindows Networking

Avatar of undefined
Last Comment
kaufmed

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
kaufmed

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
zettler92656

That works perfect.

How do I this the other way around.

(to loop from 192.168.0.1 to 192.168.0.255) and get all the host names?
kaufmed

(to loop from 192.168.0.1 to 192.168.0.255) and get all the host names?
You should be able to modify the above to accomplish this. I don't have a DNS server to test against, but I believe it should be:
Module Module1

  Sub Main()
    Const base As String = "192.168.0."

    For curr As Integer = 1 To 255
      Dim ip As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry(base & curr.ToString())

      Console.WriteLine(ip.HostName)
    Next

    Console.ReadKey()
  End Sub

End Module

Open in new window

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck