Example program to test JNET::JControlHost.  
More...
#include <string>
#include <iostream>
#include <iomanip>
#include <sstream>
#include "JNet/JControlHost.hh"
#include "JSystem/JNetwork.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
 
Go to the source code of this file.
 | 
| int  | main (int argc, char *argv[]) | 
|   | 
Example program to test JNET::JControlHost. 
- Author
 - mdejong 
 
Definition in file JControlHost.cc.
 
◆ main()
      
        
          | int main  | 
          ( | 
          int  | 
          argc,  | 
        
        
           | 
           | 
          char *  | 
          argv[]  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Definition at line 19 of file JControlHost.cc.
   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);
 
   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);
 
  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);
 
  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);
 
  158       NOTICE(
"Exception test failed: " << error.
what() << endl);
 
#define DEBUG(A)
Message macros.
 
#define ASSERT(A,...)
Assert macro.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
virtual const char * what() const override
Get error message.
 
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.