Files
2024-09-23 12:00:04 -04:00

84 lines
2.7 KiB
C++

#pragma once
/*
* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
*
* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
* and international copyright treaties.
*
* Access to and use of the software is governed by the terms of the applicable OnixS Software
* Services Agreement (the Agreement) and Customer end user license agreements granting
* a non-assignable, non-transferable and non-exclusive license to use the software
* for it's own data processing purposes under the terms defined in the Agreement.
*
* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
* of this source code or associated reference material to any other location for further reproduction
* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
*
* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
* the terms of the Agreement is a violation of copyright law.
*/
#include <OnixS/FIXEngine/ABI.h>
#include <OnixS/FIXEngine/Sockets/Definitions.h>
#include <string>
namespace OnixS {
namespace Sockets {
/// Provides the User Datagram Protocol (UDP)
/// multicast mode network services.
class ONIXS_FIXENGINE_API MulticastClient
{
public:
/// Creates a MulticastClient.
MulticastClient();
/// Finalize the instance.
virtual ~MulticastClient();
/// Adds a MulticastClient to the multicast
/// group using all network interfaces.
void join(const std::string & ip, int port);
/// Adds a MulticastClient to the multicast
/// group using the given network interface.
void join(const std::string & ip, int port, const std::string & networkInterface);
/// Leaves the multicast group.
void drop();
/// Receives a multicast packet.
///
/// @note Blocks until the packet is received.
/// @note The multicast group must be joined first.
///
/// @return The received multicast packet.
const Bytes & receive();
/// Receives a multicast packet.
///
/// @note Blocks until the packet is received or the timeout period is elapsed.
/// @note The multicast group must be joined first.
///
/// @return The received multicast packet or an empty vector if the timeout period is elapsed.
const Bytes & receive(long timeoutInMilliseconds);
/// Sends the given multicast packet.
void send(const std::string & packet);
/// Sends the given multicast packet.
void send(const void * packet, size_t packetSize);
/// The maximum UDP packet size.
enum { MaximumUdpPacketSize = 65535 };
private:
MulticastClient(const MulticastClient &);
MulticastClient & operator = (const MulticastClient &);
struct Impl;
Impl * impl_;
};
}
}