#include <iostream>
#include <cstdlib>

#include "SysPlusPlus"
#include "ComPlusPlus"


int main ( int argc, char *argv [] ) {

  if ( argc != 3 ) {
    std::cout << "Usage: " << argv [0] << " IP-Addr port \n";	
  	exit(1);
  }
  	
 int SPort = std::atoi ( argv[1] );	
 std::string MGS = argv [2];
 
try {	
  compp::SocketUdp Srv( SPort );	
  char buf[1000];
  // -> Comment 1
  Srv.SetSockOptJoinMulticastGroup(MGS);
  while ( true ) {
    memset ( buf, 0, sizeof(buf));
    Srv.Recv(buf,  sizeof(buf));  
    std::cout << "---" << buf << "---\n";
  }
  return 0;
} catch ( syspp::ComException e ) {
  std::cout << "Exception " << e.what( ) << "\n" ;	
  perror ( "Multicast Test");	
}  	
}
