main(int argc, char** argv)
{
CAVERN_irb_c::status_t
irbStatus;
CAVERN_irbId_c
remoteIRBId;
CAVERN_irbChannel_c::status_t
channelRetStatus;
CAVERN_irbKey_c::status_t
keyStatus;
/// Startup CAVERN.
CAVERN_irb_c
*personalIRB = CAVERNInit(&argc,
&argv, NULL);
if (!personalIRB)
exit(1);
/// Create a channel over which communication will occur.
CAVERN_irbChannel_c
*aChannel = personalIRB->createChannel();
/// Open the channel to a remote IRB specified on the command line.
remoteIRBId.setAddress(argv[1]);
aChannel->open(&remoteIRBId,NULL,CAVERN_irbChannel_c::UNRELIABLE,
&channelRetStatus);
/// Define the local key (called LOCAL_A_KEY)
CAVERN_irbKeyId_c
aKeyId, remote_aKeyId;
aKeyId.setName("LOCAL_A_KEY");
remote_aKeyId.setName("A_KEY");
CAVERN_irbKey_c
*aKey = personalIRB->define(&aKeyId, NULL, &irbStatus);
/// Create a link to link the local key with the remote key.
CAVERN_linkAttrib_c
linkAttribute;
linkAttribute.setInitialSynchType(CAVERN_linkAttrib_c::NONE);
CAVERN_irbLink_c
*aLink = aChannel->link(aKey, &remote_aKeyId, &linkAttribute);
int count = 0;
char mesg[256];
int size;
while(1) {
/// Put something in the local key.
sprintf(mesg,"A KEY %d",count++);
size = strlen(mesg)+1;
aKey->put(mesg,&size, &keyStatus);
sleep(2);
}
}