Feedback

Prüfen ob eine Internetverbindung vorhanden ist

Sprache: C#

Die Methode prüft mittels Ping ob eine Internetverbindung vorhanden ist (oder auch nicht;) Folgender Namespace wird benötigt: [code]using System.Net.NetworkInformation;[/code]
/// <summary>
/// Prüft ob eine Internetverbindung vorhanden ist.
/// </summary>
/// <returns>
/// true/false
/// </returns>
public static bool CheckInternetConnection()
{
	Ping ping = new Ping();

	try
	{
		PingReply reply = ping.Send("www.google.at", 100);

		return reply.Status == IPStatus.Success;
	}
	catch
	{
		return false;
	}
}
/// <summary>
/// Prüft ob eine Internetverbindung vorhanden ist.
/// </summary>
/// <returns>
/// true/false
/// </returns>
public static bool CheckInternetConnection()
{
	Ping ping = new Ping();

	try
	{
		PingReply reply = ping.Send("www.google.at", 100);

		return reply.Status == IPStatus.Success;
	}
	catch
	{
		return false;
	}
}