-
Notifications
You must be signed in to change notification settings - Fork 0
/
WindowsServer.h
53 lines (47 loc) · 1.08 KB
/
WindowsServer.h
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
/**
* @file WindowsServer.h
*
* @author John Glatts
* @brief Class definiton for the WindowsServer
* @version 0.1
* @date 2022-12-03
*
* @copyright Copyright (c) 2022
*
*/
#ifndef __WINDOWS_SERVER__
#define __WINDOWS_SERVER__
#include <winsock2.h>
#include <ws2ipdef.h>
#include <ws2tcpip.h>
#include <mstcpip.h>
#include <vector>
#define DEFAULT_PORT 8888
#define MAX_BUF_LEN 1024
using namespace std;
class WindowsServer {
public:
WindowsServer();
WindowsServer(int);
bool init(int, char**);
bool routeURL(char*);
bool runServer();
void addURL(const char*);
void addCallBack(const char*, const char* (*)(void));
void testCallBacks(const char*);
private:
typedef struct URL {
const char* url;
const char* (*url_callback)(void);
} URL;
bool initServer();
int checkURL(char*);
void parseURL(SOCKET, char*, char*);
bool getPacket(SOCKET, char*);
void sendResponse(SOCKET, char*);
int port;
SOCKET server_socket;
vector<const char*> valid_urls;
vector<URL> response_callbacks;
};
#endif // !__WINDOWS_SERVER__