-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathhttp_tcpServer_linux.h
More file actions
39 lines (32 loc) · 817 Bytes
/
Copy pathhttp_tcpServer_linux.h
File metadata and controls
39 lines (32 loc) · 817 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 INCLUDED_HTTP_TCPSERVER_LINUX
#define INCLUDED_HTTP_TCPSERVER_LINUX
#include <stdio.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string>
namespace http
{
class TcpServer
{
public:
TcpServer(std::string ip_address, int port);
~TcpServer();
void startListen();
private:
std::string m_ip_address;
int m_port;
int m_socket;
int m_new_socket;
long m_incomingMessage;
struct sockaddr_in m_socketAddress;
unsigned int m_socketAddress_len;
std::string m_serverMessage;
int startServer();
void closeServer();
void acceptConnection(int &new_socket);
std::string buildResponse();
void sendResponse();
};
} // namespace http
#endif