]> git.sesse.net Git - cubemap/blob - acceptor.h
Update version number to 1.0.1-pre.
[cubemap] / acceptor.h
1 #ifndef _ACCEPTOR_H
2 #define _ACCEPTOR_H
3
4 #include "thread.h"
5
6 enum SocketType {
7         TCP_SOCKET,
8         UDP_SOCKET,
9 };
10 int create_server_socket(int port, SocketType socket_type);
11
12 class AcceptorProto;
13
14 // A thread that accepts new connections on a given socket,
15 // and hands them off to the server pool.
16 class Acceptor : public Thread {
17 public:
18         Acceptor(int server_sock, int port);
19
20         // Serialization/deserialization.
21         Acceptor(const AcceptorProto &serialized);
22         AcceptorProto serialize() const;
23
24         void close_socket();
25
26 private:
27         virtual void do_work();
28
29         int server_sock, port;
30 };
31
32 #endif  // !defined(_ACCEPTOR_H)