-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.h
More file actions
42 lines (34 loc) · 889 Bytes
/
server.h
File metadata and controls
42 lines (34 loc) · 889 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
40
41
42
#ifndef DATABASEDIMA__SERVER_H_
#define DATABASEDIMA__SERVER_H_
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <csignal>
#include <ctime>
#include "db.h"
namespace db::server {
class Server {
private:
constexpr static char too_long_msg[] = "Message is too long, it will be skipped";
constexpr static char read_failed_msg[] = "Read failed";
enum Constants {
PORT = 8080
};
int m_opt = 1;
int m_master_socket{};
std::vector<int> m_client_sockets{};
socklen_t m_address_len{};
sockaddr_in m_address{};
db::Database m_db{};
public:
Server(int port = PORT);
void work();
};
}
#endif //DATABASEDIMA__SERVER_H_