Go to the documentation of this file. 1 #ifndef __JNET__JCONTROLHOST__
2 #define __JNET__JCONTROLHOST__
24 namespace JPP {
using namespace JNET; }
178 if (p != this->end() && p->getID() == subscription.
getID()) {
187 this->insert(subscription);
219 buffer +=
' ' + i->toString();
249 public JThrow<JControlHost>
271 return tag[0] ==
'_';
387 int MyId(
const std::string& nick_name)
427 JPrefix __prefix__(tag, length);
432 write((
char*) buffer, (
int) length);
438 return Throw(error, -1);
451 int PutFullData(
const std::string& tag,
const void* buffer,
const long long int length)
457 return Throw(error, -1);
460 return Throw(error, -2);
473 const std::string& buffer)
487 const std::string& buffer)
489 return PutFullData(tag, buffer.c_str(), buffer.size());
521 return Throw(error, -1);
533 int WaitHead(std::string& tag,
long long int& length)
569 return Throw(error, -1);
582 int CheckHead(std::string& tag,
long long int& length,
const int timeout_us = 0)
584 const int rvalue =
CheckHead(this->prefix, timeout_us);
587 tag = this->prefix.
getTag();
588 length = this->prefix.
getSize();
606 read((
char*) buffer, (
int) length);
611 return Throw(error, -1);
624 buffer.resize(this->prefix.
getSize());
626 return GetFullData((
char*) buffer.data(), buffer.size());
638 static int WhereIs(
const std::string& host_name,
639 const std::string& nick_name,
651 long long int length;
659 return Throw(error, -1);
683 return Throw(error, -1);
int PutFullString(const JTag &tag, const std::string &buffer)
Send string.
JSubscription_t subscription
Auxiliary class for time values.
static const JTag DISPTAG_Subscribe("_Subscri")
Special ControlHost tags.
JSubscriptionList operator+(const JSubscription &first, const JSubscription &second)
Add operator.
JSubscriptionList(const JSubscription &subscription)
Copy constructor.
static const JTag DISPTAG_Version("_Version")
Exception for ControlHost.
static const JTag DISPTAG_WhereIs("_WhereIs")
int write(const char *buffer, const int length)
Write data to socket.
Auxiliary class for any subscription.
static JTimeval min()
Get minimal time value.
int read(char *buffer, const int length)
Read data from socket.
int MyId(const std::string &nick_name)
Identify.
Auxiliary base class for controling the throwing of exceptions.
const JTag & getTag() const
Get tag.
int Connected()
Send version.
void setSendBufferSize(const int size)
Set send buffer size.
int GetFullData(void *buffer, long long int length)
Receive data.
JSubscription(const JSubscription_t sub, const JTag &tag)
Constructor.
void setReuseAddress(const bool on)
Set reuse address.
JSubscriptionAny(const JTag &tag)
Constructor.
Interprocess communication.
JSubscriptionList()
Default constructor.
Auxiliary base class for aritmetic operations of derived class types.
void setTcpNoDelay(const bool on)
Set TCP no-delay.
int shutdown()
Shut down socket.
const char * c_str() const
C-string.
Auxiliary data structure for hostname and port number.
void setReceiveBufferSize(const int size)
Set receive buffer size.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
static int WhereIs(const std::string &host_name, const std::string &nick_name, std::string &answer)
Locate ControlHost client(s).
JControlHost()
Default constructor.
int PutFullData(const std::string &tag, const void *buffer, const long long int length)
Send data.
bool in_avail(JTimeval timeout=JTimeval::min()) const
Check availability of input.
JControlHost(const JHostname &server)
Constructor.
static const JTag DISPTAG_Always("_Always")
static bool maybe_special(const JTag &tag)
Check special ControlHost tags.
static const int DISPATCH_PORT
Default ControlHost port.
ControlHost subscription.
JSubscription_t
ControlHost subscription types.
JControlHost(const std::string &server, const int port)
Constructor.
JTag_t getID() const
Get identifier.
JSubscriptionList & add(const JSubscription &subscription)
Add subscription.
static const std::string CHOO_VERSION
int WaitHead(JPrefix &prefix)
Wait for header.
void setKeepAlive(const bool on)
Set keep alive of socket.
std::set< JSubscription >::const_reverse_iterator const_reverse_iterator
static bool is_valid(const char c)
Check validity of subscription specifier.
JControlHost(const JSocket &socket)
Constructor.
std::string toString() const
Convert subscription to string.
static void Throw(const bool option)
Enable/disable throw option.
int PutFullData(const JTag &tag, const void *buffer, const long long int length)
Send data.
void connect(const int port)
Connect to port on local host.
int SendMeNext()
Tell server to send next message.
int WaitHead(std::string &tag, long long int &length)
Wait for header.
void setNonBlocking(const bool on)
Set non-blocking of I/O.
int PutFullString(const std::string &tag, const std::string &buffer)
Send string.
JSubscriptionList getSubscription(const JEventTable &event_table)
Convert event table to ControlHost subscription.
JSubscriptionList & add(const JSubscriptionList &subscription)
Add subscription.
int configure()
Configure socket (factory reset).
JControlHost ControlHost
Match name.
int Subscribe(const JSubscription &subscription)
Subscribe to single tag.
int Subscribe(const JSubscriptionList &subscription)
Subscribe to list of tags.
const std::set< JSubscription > * operator->() const
Smart pointer.
int GetFullString(std::string &buffer)
Receive string.
int CheckHead(std::string &tag, long long int &length, const int timeout_us=0)
Check for header, without waiting.
int SendMeAlways()
Tell server to send messages forever.
std::string toString() const
Convert tag to string.
int CheckHead(JPrefix &prefix, JTimeval timeout=JTimeval::min())
Check for header, without waiting.
JControlHost & operator=(const JControlHost &)
static const JTag DISPTAG_MyId("_MyId")
~JControlHost()
Destructor.
JSubscriptionAll(const JTag &tag)
Constructor.
int getSize() const
Get size.
JControlHost(const int ip_number, const int port=DISPATCH_PORT)
Constructor.
JSubscription_t getSubscription() const
Get subscription type.
std::string toString() const
Convert subscription list to string.
Auxiliary class for all subscription.
static const JTag DISPTAG_Gime("_Gime")
std::set< JSubscription >::const_iterator const_iterator