#ifndef __JNET__JCONTROLHOSTSERVER__ #define __JNET__JCONTROLHOSTSERVER__ #include #include "JNet/JServerSocket.hh" #include "JNet/JControlHost.hh" #include "JLang/JTimeval.hh" /** * \author mdejong */ namespace JNET {} namespace JPP { using namespace JNET; } namespace JNET { namespace { using JLANG::JTimeval; } /** * Light-weight wrapper class around server socket. */ class JControlHostServer : public JServerSocket { public: /** * Constructor. * * \param port port number * \param backlog backlog */ JControlHostServer(const int port = DISPATCH_PORT, const int backlog = 1) : JServerSocket(port, backlog) {} /** * Accept new client. * * \param timeout timeout * \return pointer to newly created ControlHost client (or NULL) */ JControlHost* AcceptClient(JTimeval timeout = JTimeval::max()) { if (in_avail(timeout)) { JTCPSocket socket; socket.accept(getFileDescriptor()); return new JControlHost(socket); } else return NULL; } }; /** * Match name. */ typedef JControlHostServer ControlServ; } #endif