X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fhdsd%2Fscd%2Fscd_init_listener.h;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fhdsd%2Fscd%2Fscd_init_listener.h;h=5ae7b5a440fc6f9a9791a03a5e6103d7ac522643;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/hdsd/scd/scd_init_listener.h b/dol/src/dol/visitor/hdsd/scd/scd_init_listener.h new file mode 100644 index 0000000..5ae7b5a --- /dev/null +++ b/dol/src/dol/visitor/hdsd/scd/scd_init_listener.h @@ -0,0 +1,73 @@ +#ifndef SCD_INIT_LISTENER_H +#define SCD_INIT_LISTENER_H + +#include + +#include "scd_sock_poller.h" +#include "scd_socket.h" +#include "scd_simulator.h" +#include "scd_in_connector.h" + +/** + * Accepts incomming connection during initialization and instanciates + * a connector that handles the new connection. + */ +class scd_init_listener : public scd_sock_ev_handler_if +{ +public: + /** + * Constructor. Binds the listener to the specified TCP port on all + * available network interfaces. + * \param sim the simulator + * \param port TCP port to bind to + */ + scd_init_listener(scd_simulator &sim, uint16_t port); + + /** + * Constructor. Binds the listener to the specified TCP port + * only on the specified network interface. + * \param sim the simulator + * \param host IP or domain name of the interface to bind to + * \param port TCP port to bind to + */ + scd_init_listener(scd_simulator &sim, + const std::string &host, uint16_t port); + + /** + * Deconstructor. + */ + virtual ~scd_init_listener(); + + /** + * Creates the listening socket. + * \exception scd_exception if unexpected errors occure + */ + void listen(); + + /** + * Closes the listening socket. + */ + void close(); + + /** + * Removes connectors that finished their job. If the optional argument + * hard is true all connectors are destroyed independend if they + * have finished or not. + * \param hard if true all connectors will be destroyed + */ + void cleanup(bool hard = false); + + /* scd_sock_ev_handler_if */ + void handle_sock_ev(sock_ev events); + const scd_socket& get_sock(); + +private: + scd_simulator &_sim; + std::string _host; + uint16_t _port; + scd_socket _socket; + std::list_connectors; + bool _handler; +}; + +#endif