forked from awwit/httpserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSocketList.h
More file actions
41 lines (34 loc) · 674 Bytes
/
SocketList.h
File metadata and controls
41 lines (34 loc) · 674 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
#pragma once
#include "Socket.h"
namespace HttpServer
{
class SocketList
{
protected:
#ifdef WIN32
HANDLE obj_list;
mutable std::vector<WSAPOLLFD> poll_events;
#elif POSIX
size_t obj_list;
mutable std::vector<struct ::epoll_event> epoll_events;
#else
#error "Undefine platform"
#endif
public:
SocketList();
bool create(const size_t = 0);
void destroy();
inline bool is_created() const
{
#ifdef WIN32
return INVALID_HANDLE_VALUE != obj_list;
#elif POSIX
return (size_t)~0 != obj_list;
#else
#error "Undefine platform"
#endif
}
bool addSocket(const Socket &);
bool accept(std::vector<Socket> &sockets) const;
};
};