-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.h
More file actions
39 lines (31 loc) · 672 Bytes
/
Copy pathserver.h
File metadata and controls
39 lines (31 loc) · 672 Bytes
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
#ifndef SERVER_H
#define SERVER_H
#include <iostream>
#include <vector>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <thread>
#include <mutex>
#define BLOCK_SIZE 16
#define MAX_MSG_SIZE BLOCK_SIZE * 64
struct MSG {
uint8_t m[MAX_MSG_SIZE];
uint8_t t[16];
int len;
};
class Server {
private:
int serv = -1;
sockaddr_in serv_addr;
void handle(int sock, std::vector<int> & clients) noexcept;
public:
void setup(const in_addr_t ipv4, const in_port_t port_num);
void run();
void stop() noexcept {
if (serv != -1) {
close(serv);
}
};
};
#endif /* SERVER_H */