-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPing.h
More file actions
60 lines (42 loc) · 1 KB
/
Ping.h
File metadata and controls
60 lines (42 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once
#include "framework.h"
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <icmpapi.h>
#include <stdio.h>
#define DISCONNECT_VALUE -1
#define PING_TIME_OUT 1000
#define BUFFER_LENGTH 32
#define PING_LOOP_INTERVAL 50
class Ping {
public:
Ping(wchar_t* server, int pingLength);
~Ping();
void setAddress(wchar_t* server);
void start();
void stop();
bool isRunning();
double getAverage();
int getPing();
int getPing(int index);
int getMax();
int getMin();
double getInstability();
private:
static DWORD WINAPI ThreadLoop(LPVOID lpParam);
int ping();
void insert(int pingValue);
HANDLE hThread;
LPWSTR server;
char* sendData[BUFFER_LENGTH];
DWORD dwRetVal;
DWORD replySize;
HANDLE hIcmpFile;
ULONG ipAddress;
addrinfoW hints, *addressInfo;
std::atomic<bool> run;
double average, instability;
int minimum, maximum;
std::auto_ptr<std::vector<int>> pingVector;
};