49 lines
1.0 KiB
C#
Executable File
49 lines
1.0 KiB
C#
Executable File
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);
|
|
}
|
|
}
|
|
}
|