Federal09
Federal09

Reputation: 649

Create Simple Ping

How to create a simple ping to website and get is online or not?

Ex:

var test = new ping()
try{
test.ping(www.google.com)
messagebox.show("your internet connection is ok");
}
catch
{
messagebox.show("you are not connected");
}

it is possible? i have searched on the web but not found nothing

Upvotes: 1

Views: 639

Answers (1)

Jonathon Reinhart
Jonathon Reinhart

Reputation: 137398

Use the WebRequest class to make an HTTP request and see if it succeeds.

Note that 'ping' is really an ICMP function, and not what you're looking for, if you're testing websites (HTTP). If you really do want to just see if you have a connection, then ping will work, and the Ping class, as squiguy mentioned.

Upvotes: 4

Related Questions