summaryrefslogtreecommitdiff
path: root/examples/RMCast/Send_Msg/Sender.cpp
blob: e784b6362c7f58e4295f99455fc512d2f299aa92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// file      : Sender.cpp
// author    : Boris Kolpackov <boris@kolpackov.net>
// cvs-id    : $Id$


#include <ace/OS.h>
#include <ace/RMCast/Socket.h>

#include <iostream>

#include "Protocol.h"

using std::cerr;
using std::endl;

class args {};

int
main (int argc, char* argv[])
{
  try
  {
    if (argc < 2) throw args ();

    ACE_RMCast::Address addr (argv[1]);

    ACE_RMCast::Socket socket (addr);

    Message msg;
    msg.sn = 0;

    for (unsigned short i = 0; i < payload_size; i++)
    {
      msg.payload[i] = i;
    }

    for (; msg.sn < message_count; msg.sn++)
    {
      socket.send (&msg, sizeof (msg));
    }

    // Keep running in case retransmissions are needed.
    //
    ACE_OS::sleep (ACE_Time_Value (50, 0));

    return 0;
  }
  catch (args const&)
  {
    cerr << "usage: " << argv[0] << " <IPv4 Multicast Address>" << endl;
  }

  return 1;
}