OnixS C++ FIX Engine  4.2.0
API Documentation
MulticastClient.h
Go to the documentation of this file.
1 #pragma once
2 /*
3 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
4 *
5 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
6 * and international copyright treaties.
7 *
8 * Access to and use of the software is governed by the terms of the applicable OnixS Software
9 * Services Agreement (the Agreement) and Customer end user license agreements granting
10 * a non-assignable, non-transferable and non-exclusive license to use the software
11 * for it's own data processing purposes under the terms defined in the Agreement.
12 *
13 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
14 * of this source code or associated reference material to any other location for further reproduction
15 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
16 *
17 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
18 * the terms of the Agreement is a violation of copyright law.
19 */
20 
21 #include <OnixS/FIXEngine/ABI.h>
22 #include <OnixS/FIXEngine/Sockets/Definitions.h>
23 
24 #include <string>
25 
26 namespace OnixS {
27 namespace Sockets {
28 /// Provides User Datagram Protocol (UDP)
29 /// multicast mode network services.
31 {
32 public:
33  /// Creates a MulticastClient.
35 
36  /// Finalize instance.
37  virtual ~MulticastClient();
38 
39  /// Adds a MulticastClient to the multicast
40  /// group using all network interfaces.
41  void join(const std::string & ip, int port);
42 
43  /// Adds a MulticastClient to the multicast
44  /// group using the given network interface.
45  void join(const std::string & ip, int port, const std::string & networkInterface);
46 
47  /// Leaves the multicast group.
48  void drop();
49 
50  /// Receives a multicast packet.
51  ///
52  /// @note Blocks until the packet is received.
53  /// @note Multicast group must be joined first.
54  ///
55  /// @return The received multicast packet.
56  const Bytes & receive();
57 
58  /// Receives a multicast packet.
59  ///
60  /// @note Blocks until the packet is received or the timeout period is elapsed.
61  /// @note Multicast group must be joined first.
62  ///
63  /// @return The received multicast packet or an empty vector if the timeout period is elapsed.
64  const Bytes & receive(long timeoutInMilliseconds);
65 
66  /// Sends the given multicast packet.
67  void send(const std::string & packet);
68 
69  /// Sends the given multicast packet.
70  void send(const void * packet, size_t packetSize);
71 
72  /// Maximum UDP packet size.
73  enum { MaximumUdpPacketSize = 65535 };
74 
75 private:
77  MulticastClient & operator = (const MulticastClient &);
78 
79  struct Impl;
80  Impl * impl_;
81 };
82 }
83 }
#define ONIXS_FIXENGINE_API
Definition: ABI.h:45
Provides User Datagram Protocol (UDP) multicast mode network services.