Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JControlHostServer.hh
Go to the documentation of this file.
1#ifndef __JNET__JCONTROLHOSTSERVER__
2#define __JNET__JCONTROLHOSTSERVER__
3
4#include <limits>
5
8#include "JLang/JTimeval.hh"
9
10
11/**
12 * \author mdejong
13 */
14
15namespace JNET {}
16namespace JPP { using namespace JNET; }
17
18namespace JNET {
19
20 namespace {
21 using JLANG::JTimeval;
22 }
23
24
25 /**
26 * Light-weight wrapper class around server socket.
27 */
29 public JServerSocket
30 {
31 public:
32 /**
33 * Constructor.
34 *
35 * \param port port number
36 * \param backlog backlog
37 */
39 const int backlog = 1) :
40 JServerSocket(port, backlog)
41 {}
42
43
44 /**
45 * Accept new client.
46 *
47 * \param timeout timeout
48 * \return pointer to newly created ControlHost client (or NULL)
49 */
51 {
52 if (in_avail(timeout)) {
53
54 JTCPSocket socket;
55
56 socket.accept(getFileDescriptor());
57
58 return new JControlHost(socket);
59
60 } else
61
62 return NULL;
63 }
64 };
65
66
67 /**
68 * Match name.
69 */
71}
72
73
74#endif
int getFileDescriptor() const
Get file descriptor.
bool in_avail(JTimeval timeout=JTimeval::min()) const
Check availability of input.
Definition JFile.hh:106
Auxiliary class for time values.
Definition JTimeval.hh:29
static JTimeval max()
Get maximal time value.
Definition JTimeval.hh:131
Light-weight wrapper class around server socket.
JControlHostServer(const int port=DISPATCH_PORT, const int backlog=1)
Constructor.
JControlHost * AcceptClient(JTimeval timeout=JTimeval::max())
Accept new client.
ControlHost class.
TCP server socket.
TCP socket.
Definition JTCPSocket.hh:30
void accept(const int server)
Accept connection from a server.
JControlHostServer ControlServ
Match name.
static const int DISPATCH_PORT
Default ControlHost port.
Definition JHostname.hh:27
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).