forked from awwit/httpserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathList.h
More file actions
53 lines (43 loc) · 1015 Bytes
/
List.h
File metadata and controls
53 lines (43 loc) · 1015 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
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#include "Socket.h"
#ifdef POSIX
#include <sys/epoll.h>
#include <netinet/in.h>
#endif
namespace Socket
{
class List
{
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 "Undefined platform"
#endif
public:
List() noexcept;
List(List &&obj) noexcept;
~List() noexcept;
bool create(const size_t startListSize = 1);
void destroy() noexcept;
bool is_created() const noexcept;
bool addSocket(const Socket &sock) noexcept;
bool removeSocket(const Socket &sock) noexcept;
bool accept(
std::vector<Socket> &sockets
) const noexcept;
bool accept(
std::vector<Socket> &sockets,
std::vector<struct sockaddr_in> &socketsAddress
) const noexcept;
bool recv(
std::vector<Socket> &sockets,
std::vector<Socket> &errors,
std::chrono::milliseconds timeout = std::chrono::milliseconds(~0)
) const noexcept;
};
}