ping .NET, IP- .
:
internal bool PingServer()
{
bool netOK = false;
byte[] AddrBytes = new byte[] { 164, 110, 12, 144 };
using (System.Net.NetworkInformation.Ping png = new System.Net.NetworkInformation.Ping())
{
System.Net.IPAddress addr;
addr = new System.Net.IPAddress(AddrBytes);
try
{
netOK = (png.Send(addr, 1500, new byte[] { 0, 1, 2, 3 }).Status == IPStatus.Success);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
netOK = false;
}
return netOK;
}
}
EDIT: :
bool ConnectionExists()
{
try
{
System.Net.Sockets.TcpClient clnt=new System.Net.Sockets.TcpClient("www.google.com",80);
clnt.Close();
return true;
}
catch(System.Exception ex)
{
return false;
}
}