Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

RMCast_IO_UDP.h

Go to the documentation of this file.
00001 // $Id: RMCast_IO_UDP.h,v 1.1.1.1 2001/12/04 14:33:17 chad Exp $
00002 
00003 // ============================================================================
00004 //
00005 // = DESCRIPTION
00006 //     Encapsulate the I/O layer for a UDP based receiver
00007 //
00008 // = AUTHOR
00009 //    Carlos O'Ryan <coryan@uci.edu>
00010 //
00011 // ============================================================================
00012 
00013 #ifndef ACE_RMCAST_IO_UDP_H
00014 #define ACE_RMCAST_IO_UDP_H
00015 #include "ace/pre.h"
00016 
00017 #include "RMCast_Module.h"
00018 #include "ace/SOCK_Dgram_Mcast.h"
00019 #include "ace/Hash_Map_Manager.h"
00020 #include "ace/Synch.h"
00021 #include "ace/INET_Addr.h"
00022 
00023 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00024 # pragma once
00025 #endif /* ACE_LACKS_PRAGMA_ONCE */
00026 
00027 class ACE_RMCast_UDP_Proxy;
00028 class ACE_RMCast_Module_Factory;
00029 class ACE_Time_Value;
00030 
00031 class ACE_RMCast_Export ACE_RMCast_IO_UDP : public ACE_RMCast_Module
00032 {
00033 public:
00034   //! Constructor
00035   /*!
00036    * The <factory> argument is used to create the modules for each
00037    * proxy that process incoming messages. The class does *not* assume
00038    * ownership of <factory>, the caller owns it.  But it does assume
00039    * ownership of the modules returned by the factory, and it may ask
00040    * the factory to release them eventually.
00041    */
00042   ACE_RMCast_IO_UDP (ACE_RMCast_Module_Factory *factory);
00043 
00044   //! Destructor
00045   ~ACE_RMCast_IO_UDP (void);
00046 
00047   /// Open the internal socket, but only to send multicast data.
00048   /**
00049    * It is not clear to me if this is a valid configuration.  Maybe it
00050    * would be a problem to expose two separate, incompatible
00051    * interfaces (check the subscribe() method). However, the
00052    * alternative would be to implement almost identical class for
00053    * outgoing and incoming UDP I/O
00054    */
00055   int init (const ACE_INET_Addr &mcast_group,
00056             const ACE_Addr &local,
00057             int protocol_family = PF_INET,
00058             int protocol = 0,
00059             int reuse_addr = 0);
00060 
00061   //! Join a new multicast group
00062   /*!
00063    * Start receiving data for the <mcast_addr> multicast group.
00064    * Please read the documentation of ACE_SOCK_Dgram_Mcast for more
00065    * details.
00066    */
00067   int subscribe (const ACE_INET_Addr &mcast_addr,
00068                  int reuse_addr = 1,
00069                  const ACE_TCHAR *net_if = 0,
00070                  int protocol_family = PF_INET,
00071                  int protocol = 0);
00072 
00073   // The class can be used with a Reactor or using blocking I/O
00074   // depending on what method of the following two is called.
00075 
00076   //! Wait for events for the period <tv>. If <tv> is zero it blocks
00077   //! forever.
00078   int handle_events (ACE_Time_Value *tv = 0);
00079 
00080   //! There is data to read, read it and process it.
00081   int handle_input (ACE_HANDLE h);
00082 
00083   //! Obtain the handle for the underlying socket
00084   ACE_HANDLE get_handle (void) const;
00085 
00086   //@{
00087   //! Send the message to the ACE_INET_Addr argument.
00088   /*!
00089    * These methods are used in the implementation of the
00090    * ACE_RMCast_UDP_Proxy objects and the implementation of the
00091    * inherited ACE_RMCast_Module methods in this class.
00092    */
00093   int send_data (ACE_RMCast::Data &, const ACE_INET_Addr &);
00094   int send_poll (ACE_RMCast::Poll &, const ACE_INET_Addr &);
00095   int send_ack_join (ACE_RMCast::Ack_Join &, const ACE_INET_Addr &);
00096   int send_ack_leave (ACE_RMCast::Ack_Leave &, const ACE_INET_Addr &);
00097   int send_ack (ACE_RMCast::Ack &, const ACE_INET_Addr &);
00098   int send_join (ACE_RMCast::Join &, const ACE_INET_Addr &);
00099   int send_leave (ACE_RMCast::Leave &, const ACE_INET_Addr &);
00100   //@}
00101 
00102   // Please read the documentation in ACE_RMCast_Module for more details
00103   virtual int data (ACE_RMCast::Data &);
00104   virtual int poll (ACE_RMCast::Poll &);
00105   virtual int ack_join (ACE_RMCast::Ack_Join &);
00106   virtual int ack_leave (ACE_RMCast::Ack_Leave &);
00107   virtual int ack (ACE_RMCast::Ack &);
00108   virtual int join (ACE_RMCast::Join &);
00109   virtual int leave (ACE_RMCast::Leave &);
00110 
00111 private:
00112 
00113   // This is necessary to satisfy the stupid xgcc for Lynx on Solaris
00114   // The compiler barfs up lisp code errors
00115   ACE_RMCast_UDP_Proxy *allocate_and_bind_proxy (ACE_RMCast_Module *module,
00116                                                  const ACE_INET_Addr &);
00117 
00118   //! The factory used to create the modules attached to each proxy
00119   ACE_RMCast_Module_Factory *factory_;
00120 
00121   //! The multicast group we subscribe and send to
00122   ACE_INET_Addr mcast_group_;
00123 
00124   //! The socket used to receive and send data
00125   ACE_SOCK_Dgram_Mcast dgram_;
00126 
00127   //! Use a Hash_Map to maintain the collection of proxies
00128   typedef ACE_Hash_Map_Manager<ACE_INET_Addr,ACE_RMCast_UDP_Proxy*,ACE_Null_Mutex> Map;
00129   //! The collection of proxies
00130   Map map_;
00131 };
00132 
00133 #if defined (__ACE_INLINE__)
00134 #include "RMCast_IO_UDP.i"
00135 #endif /* __ACE_INLINE__ */
00136 
00137 #include "ace/post.h"
00138 #endif /* ACE_RMCAST_IO_UDP_H */

Generated on Mon Jun 16 13:12:35 2003 for ACE_RMCast by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002