]> git.sesse.net Git - cubemap/blobdiff - acceptor.h
Support UDP input. Also fix some issues with socket closing.
[cubemap] / acceptor.h
index 97672338a133b0006b9203a8e33903057dd0aa33..e0a1bd54811df6e4be0a28de9f5e415d48cc53b5 100644 (file)
@@ -3,18 +3,30 @@
 
 #include "thread.h"
 
-int create_server_socket(int port);
+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.
-class AcceptorThread : public Thread {
+class Acceptor : public Thread {
 public:
-       AcceptorThread(int server_sock);
+       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;
+       int server_sock, port;
 };
 
 #endif  // !defined(_ACCEPTOR_H)