X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=acceptor.h;h=e0a1bd54811df6e4be0a28de9f5e415d48cc53b5;hp=f173e5b647e68d9c4d8cad2ac64e99b7c4523dd0;hb=0d72f384a1de672824298262ba5c427ec0aee2d6;hpb=3f82e5f8ede16a712aa0bcd0913d2d8e3689742c diff --git a/acceptor.h b/acceptor.h index f173e5b..e0a1bd5 100644 --- a/acceptor.h +++ b/acceptor.h @@ -1,10 +1,32 @@ #ifndef _ACCEPTOR_H #define _ACCEPTOR_H -int create_server_socket(int port); +#include "thread.h" + +enum SocketType { + TCP_SOCKET, + UDP_SOCKET, +}; +int create_server_socket(int port, SocketType socket_type); + +class AcceptorProto; // A thread that accepts new connections on a given socket, // and hands them off to the server pool. -void *acceptor_thread_run(void *arg); +class Acceptor : public Thread { +public: + Acceptor(int server_sock, int port); + + // Serialization/deserialization. + Acceptor(const AcceptorProto &serialized); + AcceptorProto serialize() const; + + void close_socket(); + +private: + virtual void do_work(); + + int server_sock, port; +}; #endif // !defined(_ACCEPTOR_H)