-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathServer.h
51 lines (46 loc) · 1.02 KB
/
Server.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
#ifndef SERVER_H
#define SERVER_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <signal.h>
#include <string>
#include <iostream>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <vector>
#include <map>
#include "bencode.hpp"
#include "Database.h"
#include "Logger.h"
using namespace bencode;
class Server
{
public:
Server(int _port);
~Server();
void central();
void handle_client(int newsockfd);
private:
Logger *logger;
int sockfd;
int port;
int pid;
socklen_t clilen;
struct sockaddr_in serv_addr;
struct sockaddr_in cli_addr;
static const int buffersize = 4096;
char buffer[buffersize];
Database* db;
std::string parseAndInsertMessage();
std::string getKeyFromURL(std::string);
std::string array_to_string(char* arr, int size);
std::string buildDictionary(std::string infoHash);
std::string buildErrorDict();
};
#endif