Ping a computer with VB.net?

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

Hello I am new to VB 2008 and I was wanting to ping a list of computers from
an excel file. First of all I was wondering if someone can suggest how I
should ping comps from VB.net and also if there is a way to ping many and
still know if there is a response or do I have to do one at a time?
 
Bill,

My.Computer.Network.Ping will do the trick nicely. If you want to ping many
machines, you'd probably need a thread-per-ping in order to listen for
multiple responses simultaneously.

The System.Net.NetworkInformation.Ping class does have a SendAsync method
which allows you to "fire and forget" pings, but I don't remember there
being an option to specify a callback so you'd have no way of knowing if a
response/timeout occurred (could be wrong about that though).

Hope that helps you some,
-Alex
 
Bill,

My.Computer.Network.Ping will do the trick nicely. If you want to ping many

Ewwww! :)
machines, you'd probably need a thread-per-ping in order to listen for
multiple responses simultaneously.

The System.Net.NetworkInformation.Ping class does have a SendAsync method
which allows you to "fire and forget" pings, but I don't remember there
being an option to specify a callback so you'd have no way of knowing if a
response/timeout occurred (could be wrong about that though).

When you use Ping.SendAsync, a PingCompleted event is fired when the operation
completes.
 
Thanks for the responses guys! Do any of you know offhand if there is a
method to know which ping is returned from which process...not sure how that
will work if I'm using multiple ones?
 
Thanks for the responses guys! Do any of you know offhand if there is a
method to know which ping is returned from which process...not sure how that
will work if I'm using multiple ones?

You have two things going for you here... One, the sender parameter of the
PingCompleted event is the instance of the ping class that raised the event.
Futher, the second argument of the Ping.SendAsync method is a user defined
object that you can pass in to identify or save some state. When the event
fires this token is availabe via the PingCompletedEventArgs.UserData property.
 
Back
Top