MCS: Use remote.h and cleanup header file inclusion
[remote/remote-mci.git] / mcs / HostListener.h
blobaf0b4bbc65ca88314bdb66ad345385b73f297f82
1 #ifndef REMOTE_MCS_HOSTLISTENER_H
2 #define REMOTE_MCS_HOSTLISTENER_H
4 #include "remote.h"
6 #include "mcs/FileDescriptor.h"
7 #include "mcs/Host.h"
9 namespace remote { namespace mcs {
11 /** This class listen for new host connections and creates
12 * host objects for the host connections that are accepted **/
13 class HostListener : public FileDescriptor
15 public:
16 /** Constructor sets up the host listener
17 * \param port Port on which to accept new host connections
18 **/
19 HostListener(unsigned int port);
20 /** Destructor **/
21 virtual ~HostListener();
22 private:
23 /** Create a new host if it is listed in the database.
24 * \param p_fd File descriptor for the new host connection
25 * \param client Address of the new host
26 * \returns TRUE if the host object was created, FALSE otherwise
27 **/
28 bool createHostByConnection(int p_fd, sockaddr_in& client);
29 /** Handle an event on the file descriptor.
30 * \param events Event descriptor.
31 * **/
32 void handleEvent(short events);
33 /** The local Internet socket address for serving hosts. */
34 struct sockaddr_in server;
35 /** Map of all currently connected hosts. **/
36 hostmapbykey_t hosts;
41 #endif