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];
 
   51     JControlHost socket(hostname);
 
   53     DEBUG(
"Subscription: " << tag << endl);
 
   58       socket.Subscribe(JSubscriptionAny(tag));
 
   61       socket.Subscribe(JSubscriptionAll(tag));
 
   64    socket.SendMeAlways();
 
   66     DEBUG(
"Send message: " 
   67           << 
"tag <"    << tag     << 
"> "  
   68           << 
"string <" << message << 
">" << endl);
 
   70     socket.PutFullString(tag, message);
 
   73       DEBUG(
"Test GetFullString()." << endl);
 
   78       for (useconds_t i = 0; i != 10000; ++i) {
 
   80         if (socket.CheckHead(prefix) > 0) {
 
   83                 << 
"time "   << i                << 
" us "  
   84                 << 
"tag <"   << prefix.getTag()  << 
"> "  
   85                 << 
"length " << prefix.getSize() << endl);
 
   88           socket.GetFullString(buffer);
 
   90           NOTICE(
"string <" << buffer << 
">" << endl);
 
  101       if (prefix.toString() == 
"") {
 
  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);
 
  135         socket.PutFullString(tag[0], message);
 
  139       catch(
const JException& error) {
 
  141         NOTICE(
"Exception test: " << error.what() << endl);
 
  147       DEBUG(
"Test Throw(false)." << endl);
 
  149       ControlHost::Throw(
false);
 
  151       int retcd = socket.PutFullString(tag[0], message);
 
  153       NOTICE(
"Return code test: " << retcd << endl);
 
  157     catch(
const JSocketException& error) {
 
  158       NOTICE(
"Exception test failed: " << error.what() << endl);
 
  161   catch(
const JSocketException& error) {
 
  162     FATAL(error.what() << endl);
 
int getIPnumber(const std::string &host_name)
Get IP number. 
 
Utility class to parse command line options. 
 
int main(int argc, char *argv[])
 
#define ASSERT(A,...)
Assert macro. 
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object 
 
General purpose messaging. 
 
std::string getHostname()
Get host name. 
 
Utility class to parse command line options. 
 
Hostname and IP address functions. 
 
#define DEBUG(A)
Message macros.