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
35 lines (27 loc) · 709 Bytes
/
SocketList.h
File metadata and controls
35 lines (27 loc) · 709 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
#pragma once
#include "Socket.h"
namespace HttpServer
{
class SocketList
{
protected:
#ifdef WIN32
HANDLE obj_list;
mutable std::vector<WSAPOLLFD> poll_events;
#elif POSIX
int obj_list;
mutable std::vector<struct ::epoll_event> epoll_events;
#else
#error "Undefine platform"
#endif
public:
SocketList();
bool create(const size_t startListSize = 1);
void destroy();
bool is_created() const;
bool addSocket(const Socket &sock);
bool removeSocket(const Socket &sock);
bool accept(std::vector<Socket> &sockets) const;
bool recv(std::vector<Socket> &sockets, std::vector<Socket> &errors, std::chrono::milliseconds timeout = std::chrono::milliseconds(~0) ) const;
};
};