Initial commit
This commit is contained in:
Executable
+48
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Threading;
|
||||
|
||||
namespace WoL_Manager
|
||||
{
|
||||
class PingThread
|
||||
{
|
||||
private IPAddress ip;
|
||||
private bool quit;
|
||||
private int wait_time;
|
||||
private int timeout;
|
||||
private Host host;
|
||||
|
||||
public PingThread(IPAddress ip, int wait, int timeout, Host host)
|
||||
{
|
||||
this.ip = ip;
|
||||
quit = false;
|
||||
wait_time = wait;
|
||||
this.timeout = timeout;
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public void stopThread()
|
||||
{
|
||||
quit = true;
|
||||
}
|
||||
|
||||
public void threadFunction()
|
||||
{
|
||||
string data = "1234 WoL-Manager by MatzMan";
|
||||
byte[] buffer = Encoding.ASCII.GetBytes(data);
|
||||
Ping ping = new Ping();
|
||||
PingOptions options = new PingOptions();
|
||||
options.Ttl = 64;
|
||||
options.DontFragment = true;
|
||||
do
|
||||
{
|
||||
PingReply reply = ping.Send(ip, timeout, buffer, options);
|
||||
host.LastPingResult = reply;
|
||||
Thread.Sleep(wait_time*1000);
|
||||
} while (!quit);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user