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>
271 return tag[0] ==
'_';
424 JPrefix __prefix__(tag, length);
429 write((
char*) buffer, (
int) length);
435 return Throw(error, -1);
454 return Throw(error, -1);
457 return Throw(error, -2);
486 return PutFullData(tag, buffer.c_str(), buffer.size());
518 return Throw(error, -1);
566 return Throw(error, -1);
581 const int rvalue =
CheckHead(this->prefix, timeout_us);
584 tag = this->prefix.
getTag();
585 length = this->prefix.
getSize();
603 read((
char*) buffer, (
int) length);
608 return Throw(error, -1);
621 buffer.resize(this->prefix.
getSize());
623 return GetFullData((
char*) buffer.data(), buffer.size());
648 long long int length;
656 return Throw(error, -1);
680 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.
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.
int write(const char *buffer, const int length) override
Write data to socket.
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.
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.
int read(char *buffer, const int length) override
Read data from socket.
void setTcpNoDelay(const bool on)
Set TCP no-delay.
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.
$WORKDIR ev_configure_dqsimulator txt echo process $DQ_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DQ_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'
int configure()
Configure socket (factory reset).
int GetFullData(void *buffer, long long int length)
Receive data.
JControlHost(const JTCPSocket &socket)
Constructor.
static const JTag DISPTAG_Gime("_Gime")
ControlHost subscription.
void connect(const int port)
Connect to port on local host.
JSubscriptionList getSubscription(const JEventTable &event_table)
Convert event table to ControlHost subscription.
Base class for data structures with artithmetic capabilities.
void setNonBlocking(const bool on)
Set non-blocking of I/O.
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).
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.