Do first test pings
This commit is contained in:
parent
10e32001f0
commit
4cd0375a52
@ -3,6 +3,9 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.NetworkInformation;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ISPChk
|
namespace ISPChk
|
||||||
@ -21,6 +24,45 @@ namespace ISPChk
|
|||||||
public void AddHost(Host host)
|
public void AddHost(Host host)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.WriteLine("Host added!");
|
System.Diagnostics.Debug.WriteLine("Host added!");
|
||||||
|
var t = Task.Run(() => {
|
||||||
|
|
||||||
|
Ping pingSender = new Ping();
|
||||||
|
|
||||||
|
// Create a buffer of 32 bytes of data to be transmitted.
|
||||||
|
string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||||
|
byte[] buffer = Encoding.ASCII.GetBytes(data);
|
||||||
|
|
||||||
|
// Wait 10 seconds for a reply.
|
||||||
|
int timeout = 5000;
|
||||||
|
|
||||||
|
// Set options for transmission:
|
||||||
|
// The data can go through 64 gateways or routers
|
||||||
|
// before it is destroyed, and the data packet
|
||||||
|
// cannot be fragmented.
|
||||||
|
PingOptions options = new PingOptions(64, true);
|
||||||
|
|
||||||
|
System.Diagnostics.Debug.WriteLine("Pinging " + host.Name);
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
// Send the request.
|
||||||
|
PingReply reply = pingSender.Send(host.HostName, timeout, buffer, options);
|
||||||
|
|
||||||
|
if (reply.Status == IPStatus.Success)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine("Reply from "+reply.Address.ToString()+
|
||||||
|
": bytes="+reply.Buffer.Length+
|
||||||
|
" time="+ reply.RoundtripTime+"ms");
|
||||||
|
//System.Diagnostics.Debug.WriteLine("Time to live: {0}", reply.Options.Ttl);
|
||||||
|
//System.Diagnostics.Debug.WriteLine("Don't fragment: {0}", reply.Options.DontFragment);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine(reply.Status);
|
||||||
|
}
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
ISPChk/ispchk.db
BIN
ISPChk/ispchk.db
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user