OpenCOVER
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 <BR>
   default values:
      - No loopback support, means no client is running on the server's host
      - last 100 messages to hold on the server's side for recovery
      - MTU set to 576 bytes
      - debuglevel=1 (only errors are reported)
      - 3 retries if synchronization fails
      - multicast address 224.223.222.221
      - multicast interface chosen by kernel
      - read timeout on server side 2 seconds
      - read timeout on client side 5 seconds

  <BR>
  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.
  <BR>
  <PRE>

  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

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 
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

opencover::Rel_Mcast::Rel_Mcast ( int  portnumber,
int  number_clients,
const char *  addr = "224.223.222.221",
const char *  interfaceName = 0 
)
opencover::Rel_Mcast::Rel_Mcast ( int  portnumber,
const char *  addr = "224.223.222.221",
const char *  interfaceName = 0 
)
opencover::Rel_Mcast::~Rel_Mcast ( )
opencover::Rel_Mcast::Rel_Mcast ( bool  server,
int  numClients,
const char *  addr = MCAST_ADDR,
int  port = MCAST_PORT,
const char *  interface = MCAST_IFACE 
)
opencover::Rel_Mcast::Rel_Mcast ( int  clientNum,
const char *  addr = MCAST_ADDR,
int  port = MCAST_PORT,
const char *  interface = MCAST_IFACE 
)
opencover::Rel_Mcast::~Rel_Mcast ( )

Member Function Documentation

RM_Error_Type opencover::Rel_Mcast::init ( )
RM_Error_Type opencover::Rel_Mcast::init ( )
int opencover::Rel_Mcast::kill_clients ( )
RM_Error_Type opencover::Rel_Mcast::read_mcast ( void *  ,
int  ,
bool   
)
RM_Error_Type opencover::Rel_Mcast::read_mcast ( void *  dest,
int  length 
)
void opencover::Rel_Mcast::set_debuglevel ( int  )
void opencover::Rel_Mcast::set_loopback ( uchar  )
void opencover::Rel_Mcast::set_msg_buffer ( int  )
void opencover::Rel_Mcast::set_mtu ( int  )
void opencover::Rel_Mcast::set_readtimeout ( int  )
void opencover::Rel_Mcast::set_retry_counter ( int  )
void opencover::Rel_Mcast::set_sock_buffsize ( int  sbs)
RM_Error_Type opencover::Rel_Mcast::setBackoffFactor ( double  factor)
RM_Error_Type opencover::Rel_Mcast::setBlocksAndParity ( int  b,
int  p 
)
RM_Error_Type opencover::Rel_Mcast::setBufferSpace ( unsigned int  bytes)
RM_Error_Type opencover::Rel_Mcast::setDebugLevel ( int  lvl)
RM_Error_Type opencover::Rel_Mcast::setInterface ( const char *  iface)
RM_Error_Type opencover::Rel_Mcast::setLoopback ( bool  lb)
RM_Error_Type opencover::Rel_Mcast::setMaxLength ( int  m)
RM_Error_Type opencover::Rel_Mcast::setMTU ( int  bytes)
RM_Error_Type opencover::Rel_Mcast::setNumClients ( int  n)
RM_Error_Type opencover::Rel_Mcast::setRetryTimeout ( int  u)
RM_Error_Type opencover::Rel_Mcast::setSockBufferSize ( int  bytes)
RM_Error_Type opencover::Rel_Mcast::setTimeout ( int  t)
RM_Error_Type opencover::Rel_Mcast::setTTL ( int  t)
RM_Error_Type opencover::Rel_Mcast::setTxCacheBounds ( unsigned int  bytes,
int  min,
int  max 
)
RM_Error_Type opencover::Rel_Mcast::setTxRate ( int  Mbps)
RM_Error_Type opencover::Rel_Mcast::write_mcast ( const void *  ,
int  ,
bool   
)
RM_Error_Type opencover::Rel_Mcast::write_mcast ( const void *  data,
int  length 
)

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