19 int main(
int argc,
char* argv[])
32 JParser<> zap(
"Example program to test communication with JControlHost server.");
36 zap[
'm'] =
make_field(message) =
"hello world";
42 catch(
const exception &error) {
43 FATAL(error.what() << endl);
47 const string pid = argv[0];
53 DEBUG(
"Subscription: " << tag << endl);
66 DEBUG(
"Send message: "
67 <<
"tag <" << tag <<
"> "
68 <<
"string <" << message <<
">" << endl);
73 DEBUG(
"Test GetFullString()." << endl);
78 for (useconds_t i = 0; i != 10000; ++i) {
83 <<
"time " << i <<
" us "
84 <<
"tag <" << prefix.
getTag() <<
"> "
85 <<
"length " << prefix.
getSize() << endl);
90 NOTICE(
"string <" << buffer <<
">" << endl);
102 FATAL(
"Timeout." << endl);
108 DEBUG(
"Test WhereIs()." << endl);
112 ControlHost::WhereIs(hostname, pid, answer);
114 istringstream is(answer);
116 for (
string buffer; is >> buffer; ) {
118 NOTICE(
"Host: " << buffer << endl);
127 DEBUG(
"Test Throw(true)." << endl);
133 ControlHost::Throw(
true);
141 NOTICE(
"Exception test: " << error.
what() << endl);
147 DEBUG(
"Test Throw(false)." << endl);
149 ControlHost::Throw(
false);
153 NOTICE(
"Return code test: " << retcd << endl);
158 NOTICE(
"Exception test failed: " << error.
what() << endl);
162 FATAL(error.what() << endl);
int main(int argc, char *argv[])
General purpose messaging.
#define DEBUG(A)
Message macros.
#define ASSERT(A,...)
Assert macro.
Hostname and IP address functions.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
virtual const char * what() const override
Get error message.
int MyId(const std::string &nick_name)
Identify.
int PutFullString(const JTag &tag, const std::string &buffer)
Send string.
int GetFullString(std::string &buffer)
Receive string.
int CheckHead(JPrefix &prefix, JTimeval timeout=JTimeval::min())
Check for header, without waiting.
int SendMeAlways()
Tell server to send messages forever.
int Subscribe(const JSubscription &subscription)
Subscribe to single tag.
int getSize() const
Get size.
std::string toString() const
Convert tag to string.
const JTag & getTag() const
Get tag.
Utility class to parse command line options.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
int getIPnumber(const std::string &host_name)
Get IP number.
std::string getHostname()
Get host name.
Auxiliary class for all subscription.
Auxiliary class for any subscription.