-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHttpServer.h
46 lines (33 loc) · 888 Bytes
/
HttpServer.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
#ifndef __HTTPSERVER_H_
#define __HTTPSERVER_H_
#include "HttpHeader.h"
#define MAX_CLIENT 1000
typedef map<SOCKET, class CHttpSession*> HttpSessionMap;
class CHttpServer
{
friend class CHttpSession;
public:
CHttpServer(void);
~CHttpServer(void);
int Start(const unsigned short usPort, const char* szRootPath = ".", int nMaxClient = MAX_CLIENT);
int Stop();
int Pause();
int Resume();
private:
string m_strRootPath;
SOCKET m_sockListener;
SOCKADDR_IN m_stLocalAddr;
pthread_mutex_t m_csForSessionMap;
HttpSessionMap m_mapSession;
volatile bool m_bExit;
volatile bool m_bPaused;
pthread_t m_hAcceptThread;
static void* ListenThread(void* pParam);
int AcceptClient();
int AddClient(SOCKET sock, SOCKADDR_IN remoteAddr);
int DelClient(SOCKET sock);
pthread_mutex_t m_csForExitClient;
queue<SOCKET> m_queueExitClient;
int ExitClient(SOCKET sock);
};
#endif