#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "RHexCom.hh"
#define STREAM_ID 100
struct StreamStruct {
int a, b;
unsigned char c;
};
int main(int argc, char** argv)
{
if (argc != 4) {
fprintf(stderr,"Usage: stream_source <port> <dest_machine> <dest_port>\n");
exit(-1);
}
unsigned short port = atoi(argv[1]);
CommManager* mgr = new CommManager(port);
StreamSource* source =
mgr->createStreamSource(argv[2], atoi(argv[3]),
sizeof(StreamStruct), STREAM_ID);
StreamStruct ss;
for (int i=1;;i++) {
ss.a = i; ss.b = 2*i; ss.c = i % 2;
Message* msg = source->createMsg();
msg->setStruct<StreamStruct>(&ss);
source->sendMsg(msg);
printf("Sent %d (queuing %d for acknowledgement)\n", i,
source->numToSend());
if (source->numToSend() > 10)
break;
usleep(500000);
}
delete mgr;
}