Main Page | Modules | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

Example on how to set up a ping of a remote communications manager

This page illustrates an example program which deliberately misuses the RemoteManager facility to set up a ping of a remote communications manager.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "RHexCom.hh"

int main(int argc, char** argv)
{
  if (argc != 4) {
    fprintf(stderr, "Usage: ping_test <port> <dest_machine> <dest_port>\n");
    exit(-1);
  }
  
  unsigned short port = atoi(argv[1]);
  CommManager* mgr = new CommManager(port);

  RemoteManager* remote = mgr->openRemote(argv[2], atoi(argv[3]));
  remote->setTimeStamp(CommManager::now()); // kick off the ping

  while (1) {
    printf("Last contacted %d\n", remote->lastContactTime());
    sleep(1);
  }

  delete mgr;
}

RHexLib Reference Documentation