OpenCOVER
Public Types | Public Member Functions | List of all members
opencover::Rel_Mcast Class Reference

#include <rel_mcast-old.h>

Public Types

enum  RM_Error_Type {
  RM_OK , RM_TIMEOUT_ERROR , RM_SOCK_ERROR , RM_WRITE_ERROR ,
  RM_READ_ERROR , RM_ALLOC_ERROR , RM_SYNC_ERROR , RM_OK ,
  RM_INIT_ERROR , RM_SETTING_ERROR , RM_WRITE_ERROR , RM_READ_ERROR
}
 Error Codes. More...
 
enum  RM_Error_Type {
  RM_OK , RM_TIMEOUT_ERROR , RM_SOCK_ERROR , RM_WRITE_ERROR ,
  RM_READ_ERROR , RM_ALLOC_ERROR , RM_SYNC_ERROR , RM_OK ,
  RM_INIT_ERROR , RM_SETTING_ERROR , RM_WRITE_ERROR , RM_READ_ERROR
}
 

Public Member Functions

 Rel_Mcast (int portnumber, int number_clients, const char *addr="224.223.222.221", const char *interfaceName=0)
 
 Rel_Mcast (int portnumber, const char *addr="224.223.222.221", const char *interfaceName=0)
 
 ~Rel_Mcast ()
 
RM_Error_Type init ()
 
RM_Error_Type write_mcast (const void *, int, bool)
 
RM_Error_Type read_mcast (void *, int, bool)
 
int kill_clients ()
 
void set_sock_buffsize (int sbs)
 
void set_debuglevel (int)
 
void set_loopback (uchar)
 
void set_mtu (int)
 
void set_readtimeout (int)
 
void set_msg_buffer (int)
 
void set_retry_counter (int)
 
 Rel_Mcast (bool server, int numClients, const char *addr=MCAST_ADDR, int port=MCAST_PORT, const char *interface=MCAST_IFACE)
 
 Rel_Mcast (int clientNum, const char *addr=MCAST_ADDR, int port=MCAST_PORT, const char *interface=MCAST_IFACE)
 
 ~Rel_Mcast ()
 
RM_Error_Type init ()
 
RM_Error_Type write_mcast (const void *data, int length)
 
RM_Error_Type read_mcast (void *dest, int length)
 
RM_Error_Type setDebugLevel (int lvl)
 
RM_Error_Type setLoopback (bool lb)
 
RM_Error_Type setTxRate (int Mbps)
 
RM_Error_Type setTimeout (int t)
 
RM_Error_Type setRetryTimeout (int u)
 
RM_Error_Type setNumClients (int n)
 
RM_Error_Type setTxCacheBounds (unsigned int bytes, int min, int max)
 
RM_Error_Type setBackoffFactor (double factor)
 
RM_Error_Type setSockBufferSize (int bytes)
 
RM_Error_Type setInterface (const char *iface)
 
RM_Error_Type setTTL (int t)
 
RM_Error_Type setBufferSpace (unsigned int bytes)
 
RM_Error_Type setMTU (int bytes)
 
RM_Error_Type setBlocksAndParity (int b, int p)
 
RM_Error_Type setMaxLength (int m)
 

Detailed Description

This class provides reliable multicast messages over UDP
default values:


Here is an example code fragment to generate a multicast server which sends some messsages to 3 clients and one of the clients which reads these messages.


  For the server:

  // Create a multicast server (e.g. port number 23232 and 3 clients)
  Rel_Mcast* mc = new Rel_Mcast(23232, 3);
  char* buffer;

  buffer = new char[10000];
  // highest debug level
  mc->set_debuglevel(3);
  // No loopback support (default)
  mc->set_loopback(0);
  // Set the MTU (e.g. 1500 bytes for Ethernet)
  mc->set_mtu(1500);
  // last 50 messages to hold
  mc->set_msg_buffer(50);
  mc->set_readtimeout(2);
  //Initialization
  if (mc->init() != Rel_Mcast::RM_OK)
  {
  delete mc;
  return -1;
  }
  // write 10000 bytes without synchronization afterwards
  if(mc->write_mcast(buffer, 10000, 0) != Rel_Mcast::RM_OK)
  {
  mc->kill_clients();
  delete[] buffer;
  delete mc;
  return -1;
  }
  // write 10000 bytes with synchronization afterwards
  if(mc->write_mcast(buffer, 10000, 1) != Rel_Mcast::RM_OK)
  {
  mc->kill_clients();
  delete[] buffer;
  delete mc;
  return -1;
  }
  // just synchronize
  if(mc->write_mcast(0, 0, 1) != Rel_Mcast::RM_OK)
  {
  mc->kill_clients();
  delete[] buffer;
  delete mc;
  return -1;
  }
  delete[] buffer;
  delete mc;

  For a client:

  Rel_Mcast* mc = new Rel_Mcast(23232);
  char* buffer;

  buffer = new char[10000];
  mc->set_debuglevel(3);
  mc->set_mtu(1500);
  mc->set_readtimeout(10);
  if (mc->init() != Rel_Mcast::RM_OK)
  {
  delete[] buffer;
  delete mc;
  return -1;
  }
  if (mc->read_mcast(buffer, 10000, 0) != Rel_Mcast::RM_OK)
  {
  delete[] buffer;
  delete mc;
  return -1;
  }
  if (mc->read_mcast(buffer, 10000, 1) != Rel_Mcast::RM_OK)
  {
  delete[] buffer;
  delete mc;
  return -1;
  }
  if (mc->read_mcast(0, 0, 1) != Rel_Mcast::RM_OK)
  {
  delete[] buffer;
  delete mc;
  return -1;
  }
  delete mc;
  delete[] buffer;
  
Author
Michael Poehnl

Member Enumeration Documentation

◆ RM_Error_Type [1/2]

Error Codes.

Enumerator
RM_OK 

no error

RM_TIMEOUT_ERROR 
RM_SOCK_ERROR 
RM_WRITE_ERROR 
RM_READ_ERROR 
RM_ALLOC_ERROR 
RM_SYNC_ERROR 
RM_OK 

no error

RM_INIT_ERROR 
RM_SETTING_ERROR 
RM_WRITE_ERROR 
RM_READ_ERROR 

◆ RM_Error_Type [2/2]

Enumerator
RM_OK 

no error

RM_TIMEOUT_ERROR 
RM_SOCK_ERROR 
RM_WRITE_ERROR 
RM_READ_ERROR 
RM_ALLOC_ERROR 
RM_SYNC_ERROR 
RM_OK 

no error

RM_INIT_ERROR 
RM_SETTING_ERROR 
RM_WRITE_ERROR 
RM_READ_ERROR 

Constructor & Destructor Documentation

◆ Rel_Mcast() [1/4]

opencover::Rel_Mcast::Rel_Mcast ( int  portnumber,
int  number_clients,
const char *  addr = "224.223.222.221",
const char *  interfaceName = 0 
)

◆ Rel_Mcast() [2/4]

opencover::Rel_Mcast::Rel_Mcast ( int  portnumber,
const char *  addr = "224.223.222.221",
const char *  interfaceName = 0 
)

◆ ~Rel_Mcast() [1/2]

opencover::Rel_Mcast::~Rel_Mcast ( )

◆ Rel_Mcast() [3/4]

opencover::Rel_Mcast::Rel_Mcast ( bool  server,
int  numClients,
const char *  addr = MCAST_ADDR,
int  port = MCAST_PORT,
const char *  interface = MCAST_IFACE 
)

◆ Rel_Mcast() [4/4]

opencover::Rel_Mcast::Rel_Mcast ( int  clientNum,
const char *  addr = MCAST_ADDR,
int  port = MCAST_PORT,
const char *  interface = MCAST_IFACE 
)

◆ ~Rel_Mcast() [2/2]

opencover::Rel_Mcast::~Rel_Mcast ( )

Member Function Documentation

◆ init() [1/2]

RM_Error_Type opencover::Rel_Mcast::init ( )

◆ init() [2/2]

RM_Error_Type opencover::Rel_Mcast::init ( )

◆ kill_clients()

int opencover::Rel_Mcast::kill_clients ( )

◆ read_mcast() [1/2]

RM_Error_Type opencover::Rel_Mcast::read_mcast ( void *  ,
int  ,
bool   
)

◆ read_mcast() [2/2]

RM_Error_Type opencover::Rel_Mcast::read_mcast ( void *  dest,
int  length 
)

◆ set_debuglevel()

void opencover::Rel_Mcast::set_debuglevel ( int  )

◆ set_loopback()

void opencover::Rel_Mcast::set_loopback ( uchar  )

◆ set_msg_buffer()

void opencover::Rel_Mcast::set_msg_buffer ( int  )

◆ set_mtu()

void opencover::Rel_Mcast::set_mtu ( int  )

◆ set_readtimeout()

void opencover::Rel_Mcast::set_readtimeout ( int  )

◆ set_retry_counter()

void opencover::Rel_Mcast::set_retry_counter ( int  )

◆ set_sock_buffsize()

void opencover::Rel_Mcast::set_sock_buffsize ( int  sbs)

◆ setBackoffFactor()

RM_Error_Type opencover::Rel_Mcast::setBackoffFactor ( double  factor)

◆ setBlocksAndParity()

RM_Error_Type opencover::Rel_Mcast::setBlocksAndParity ( int  b,
int  p 
)

◆ setBufferSpace()

RM_Error_Type opencover::Rel_Mcast::setBufferSpace ( unsigned int  bytes)

◆ setDebugLevel()

RM_Error_Type opencover::Rel_Mcast::setDebugLevel ( int  lvl)

◆ setInterface()

RM_Error_Type opencover::Rel_Mcast::setInterface ( const char *  iface)

◆ setLoopback()

RM_Error_Type opencover::Rel_Mcast::setLoopback ( bool  lb)

◆ setMaxLength()

RM_Error_Type opencover::Rel_Mcast::setMaxLength ( int  m)

◆ setMTU()

RM_Error_Type opencover::Rel_Mcast::setMTU ( int  bytes)

◆ setNumClients()

RM_Error_Type opencover::Rel_Mcast::setNumClients ( int  n)

◆ setRetryTimeout()

RM_Error_Type opencover::Rel_Mcast::setRetryTimeout ( int  u)

◆ setSockBufferSize()

RM_Error_Type opencover::Rel_Mcast::setSockBufferSize ( int  bytes)

◆ setTimeout()

RM_Error_Type opencover::Rel_Mcast::setTimeout ( int  t)

◆ setTTL()

RM_Error_Type opencover::Rel_Mcast::setTTL ( int  t)

◆ setTxCacheBounds()

RM_Error_Type opencover::Rel_Mcast::setTxCacheBounds ( unsigned int  bytes,
int  min,
int  max 
)

◆ setTxRate()

RM_Error_Type opencover::Rel_Mcast::setTxRate ( int  Mbps)

◆ write_mcast() [1/2]

RM_Error_Type opencover::Rel_Mcast::write_mcast ( const void *  ,
int  ,
bool   
)

◆ write_mcast() [2/2]

RM_Error_Type opencover::Rel_Mcast::write_mcast ( const void *  data,
int  length 
)

The documentation for this class was generated from the following files: