1 #ifndef __JNET__JCONTROLHOST__
2 #define __JNET__JCONTROLHOST__
24 namespace JPP {
using namespace JNET; }
133 public JMath<JSubscriptionList>
179 if (p != this->end() && p->getID() == subscription.
getID()) {
188 this->insert(subscription);
220 buffer +=
' ' + i->toString();
250 public JThrow<JControlHost>
272 return tag[0] ==
'_';
388 int MyId(
const std::string& nick_name)
428 JPrefix __prefix__(tag, length);
433 write((
char*) buffer, (
int) length);
439 return Throw(error, -1);
452 int PutFullData(
const std::string& tag,
const void* buffer,
const long long int length)
458 return Throw(error, -1);
461 return Throw(error, -2);
474 const std::string& buffer)
488 const std::string& buffer)
490 return PutFullData(tag, buffer.c_str(), buffer.size());
522 return Throw(error, -1);
534 int WaitHead(std::string& tag,
long long int& length)
570 return Throw(error, -1);
583 int CheckHead(std::string& tag,
long long int& length,
const int timeout_us = 0)
585 const int rvalue =
CheckHead(this->prefix, timeout_us);
588 tag = this->prefix.
getTag();
589 length = this->prefix.
getSize();
607 read((
char*) buffer, (
int) length);
612 return Throw(error, -1);
625 buffer.resize(this->prefix.
getSize());
627 return GetFullData((
char*) buffer.data(), buffer.size());
639 static int WhereIs(
const std::string& host_name,
640 const std::string& nick_name,
652 long long int length;
660 return Throw(error, -1);
684 return Throw(error, -1);
void setReuseAddress(const bool on)
Set reuse address.
static const JTag DISPTAG_Subscribe("_Subscri")
Special ControlHost tags.
JSubscription_t getSubscription() const
Get subscription type.
int Subscribe(const JSubscriptionList &subscription)
Subscribe to list of tags.
static const int DISPATCH_PORT
Default ControlHost port.
JSubscriptionAll(const JTag &tag)
Constructor.
Auxiliary base class for aritmetic operations of derived class types.
int MyId(const std::string &nick_name)
Identify.
int CheckHead(std::string &tag, long long int &length, const int timeout_us=0)
Check for header, without waiting.
JSubscription_t
ControlHost subscription types.
int write(const char *buffer, const int length)
Write data to socket.
static const std::string CHOO_VERSION
const char * c_str() const
C-string.
void setSendBufferSize(const int size)
Set send buffer size.
int Connected()
Send version.
JSubscriptionList(const JSubscription &subscription)
Copy constructor.
int WaitHead(std::string &tag, long long int &length)
Wait for header.
Auxiliary base class for controling the throwing of exceptions.
static JTimeval min()
Get minimal time value.
const std::set< JSubscription > * operator->() const
Smart pointer.
int PutFullString(const std::string &tag, const std::string &buffer)
Send string.
static const JTag DISPTAG_MyId("_MyId")
std::string toString() const
Convert subscription list to string.
int Subscribe(const JSubscription &subscription)
Subscribe to single tag.
int SendMeAlways()
Tell server to send messages forever.
std::set< JSubscription >::const_reverse_iterator const_reverse_iterator
static const JTag DISPTAG_WhereIs("_WhereIs")
Auxiliary data structure for hostname and port number.
std::string toString() const
Convert subscription to string.
int getSize() const
Get size.
JControlHost(const JSocket &socket)
Constructor.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
static const JTag DISPTAG_Version("_Version")
Auxiliary class for time values.
int CheckHead(JPrefix &prefix, JTimeval timeout=JTimeval::min())
Check for header, without waiting.
bool in_avail(JTimeval timeout=JTimeval::min()) const
Check availability of input.
JSubscription(const JSubscription_t sub, const JTag &tag)
Constructor.
JSubscriptionList()
Default constructor.
JControlHost(const std::string &server, const int port)
Constructor.
int PutFullData(const std::string &tag, const void *buffer, const long long int length)
Send data.
JControlHost(const int ip_number, const int port=DISPATCH_PORT)
Constructor.
JControlHost(const JHostname &server)
Constructor.
int GetFullString(std::string &buffer)
Receive string.
std::set< JSubscription >::const_iterator const_iterator
int shutdown()
Shut down socket.
JControlHost ControlHost
Match name.
int SendMeNext()
Tell server to send next message.
JTag_t getID() const
Get identifier.
Auxiliary class for any subscription.
JSubscriptionList & add(const JSubscriptionList &subscription)
Add subscription.
JControlHost & operator=(const JControlHost &)
JSubscriptionList & add(const JSubscription &subscription)
Add subscription.
Exception for ControlHost.
Auxiliary class for all subscription.
JSubscriptionAny(const JTag &tag)
Constructor.
static bool is_valid(const char c)
Check validity of subscription specifier.
const JTag & getTag() const
Get tag.
static bool maybe_special(const JTag &tag)
Check special ControlHost tags.
void setReceiveBufferSize(const int size)
Set receive buffer size.
Vec operator+(const Vec &a, const Vec &b)
Add two vectors.
int WaitHead(JPrefix &prefix)
Wait for header.
std::string toString() const
Convert tag to string.
int configure()
Configure socket (factory reset).
int GetFullData(void *buffer, long long int length)
Receive data.
static const JTag DISPTAG_Gime("_Gime")
ControlHost subscription.
void connect(const int port)
Connect to port on local host.
void setNonBlocking(const bool on)
Set non-blocking of I/O.
JSubscriptionList getSubscription(const JEventTable &event_table)
Convert event table to ControlHost subscription.
Base class for data structures with artithmetic capabilities.
void setKeepAlive(const bool on)
Set keep alive of socket.
static int WhereIs(const std::string &host_name, const std::string &nick_name, std::string &answer)
Locate ControlHost client(s).
void setTcpNoDelay(const bool on)
Set TCP no-delay.
int read(char *buffer, const int length)
Read data from socket.
static const JTag DISPTAG_Always("_Always")
~JControlHost()
Destructor.
JSubscription_t subscription
int PutFullData(const JTag &tag, const void *buffer, const long long int length)
Send data.
static void Throw(const bool option)
Enable/disable throw option.
int PutFullString(const JTag &tag, const std::string &buffer)
Send string.
JControlHost()
Default constructor.