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
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of zettler92656
zettler92656
Flag of United States of America image

ASKER

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?
Avatar of kaufmed
kaufmed
Flag of United States of America image

(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

Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo