Communication sender object To create a sender use the AutoRef factory and the create(const AString& spec) method. The first spec field (':' sparated) must contain the type name of implementation. Current avalaible implementation type in NtoolBox are: "SHM" for shared memory communication (restricted to interprocess) "TCPIP" for TCPIP communications "SHD" for shared directory communication The second field must contain the address of the connection SHM : the name of the shared memeory object TCPIP : the "<IP NUMBER OR HOST NAME>:<PORT NUMBER>"
- Todo:
- missing check_connection()
#include "commore/Commore.h"
#include "commore/Sender.h"
#include "commore/Error.h"
#include "commore/Tuple.h"
#include "commore/LogHook.h"
#include <stdio.h>
CMR_MODULE_DECLARE("EXAMPLE_SENDER");
CMR_FILE_DECLARE();
using namespace std;
using namespace commore;
int main(int argc, const char* argv[])
{
int r= 0;
int count = 0;
init();
AString address =
"TCPIP:localhost:6666";
CMR_INFO("Start example Sender");
Tuple p; sender->get_param(p);
CMR_INFO(
"Address:%0") << p.
get_astring(
"address");
int c = getchar();
while (c != '.')
{
if (c == 'a')
{
in_arg.
set_int(
"count", count);
int rr = sender->call(in_arg, out_arg);
CMR_INFO(
"call count=%0 = %1") << out_arg.
get_int(
"count") << rr;
count++;
}
c = getchar();
}
CMR_INFO("Stop example Sender");
return r;
}