MulticastClient.h

Go to the documentation of this file.
00001 #if !defined MulticastClient_h
00002 #define MulticastClient_h
00003 
00004 /*
00005 * (c) Onix Solutions.
00006 */
00007 
00008 #include <vector>
00009 
00010 #include "./FIXEngineDefines.h"
00011 #include "EngineException.h"
00012 
00013 namespace FIXForge{
00014 namespace Sockets{
00015 
00016 /**
00017  * Provides User Datagram Protocol (UDP) multicast mode network services.
00018  */
00019 class FF_API MulticastClient
00020 {
00021 public:
00022     /// Creates a MulticastClient.
00023     MulticastClient();
00024 
00025     /// Destructor.
00026     virtual ~MulticastClient();
00027 
00028     /// Adds a MulticastClient to the multicast group using all network interfaces.
00029     void join(const std::string& ip, int port);
00030 
00031     /// Adds a MulticastClient to the multicast group using the given network interface.
00032     void join(const std::string& ip, int port, const std::string& networkInterface);
00033 
00034     /// Leaves the multicast group.
00035     void drop();
00036 
00037     /**
00038      * Receives a multicast packet. 
00039      *
00040      * @note Blocks until the packet is received.
00041      * @note Multicast group must be joined first.
00042      *
00043      * @return The received multicast packet.
00044      */
00045     const std::vector<char>& receive();
00046 
00047     /**
00048      * Receives a multicast packet. 
00049      *
00050      * @note Blocks until the packet is received or the timeout period is elapsed.
00051      * @note Multicast group must be joined first.
00052      *
00053      * @return The received multicast packet or an empty vector if the timeout period is elapsed.
00054      */
00055     const std::vector<char>& receive(long timeoutInMilliseconds);
00056 
00057     /**
00058      * Sends the given multicast packet. 
00059      */
00060     void send(const std::string& packet);
00061 
00062     /**
00063      * Sends the given multicast packet. 
00064      */
00065     void send(const char* packet, size_t packetSize);
00066     
00067 private:
00068     MulticastClient(const MulticastClient&);
00069     MulticastClient& operator = (const MulticastClient&);
00070 
00071     bool isJoined_;
00072 
00073     struct Impl;
00074     Impl* impl_;
00075 };
00076 
00077 }};
00078 
00079 #endif

Generated on Thu Jul 31 12:55:03 2008 for FIXForge C++ FIX Engine by  doxygen 1.5.2