00001 // -*- C++ -*- 00002 00003 /** 00004 * @file ECG_UDP_Out_Endpoint.h 00005 * 00006 * ECG_UDP_Out_Endpoint.h,v 1.10 2006/03/15 07:52:21 jtc Exp 00007 * 00008 * @author Carlos O'Ryan (coryan@cs.wustl.edu) 00009 * @author Marina Spivak (marina@atdesk.com) 00010 */ 00011 00012 #ifndef TAO_ECG_UDP_OUT_ENDPOINT_H 00013 #define TAO_ECG_UDP_OUT_ENDPOINT_H 00014 00015 #include /**/ "ace/pre.h" 00016 00017 #include /**/ "orbsvcs/Event/event_serv_export.h" 00018 00019 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00020 # pragma once 00021 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00022 00023 #include "tao/Basic_Types.h" 00024 #include "tao/orbconf.h" 00025 00026 #include "ace/Refcounted_Auto_Ptr.h" 00027 #include "ace/SOCK_Dgram.h" 00028 #include "ace/Atomic_Op.h" 00029 00030 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00031 class ACE_INET_Addr; 00032 ACE_END_VERSIONED_NAMESPACE_DECL 00033 00034 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00035 00036 /** 00037 * @class TAO_ECG_UDP_Out_Endpoint 00038 * 00039 * @brief Maintains information about an outgoing endpoint. 00040 * 00041 * UDP senders can share a single endpoint to send UDP packets, 00042 * but there is more state associated with this endpoint than its 00043 * datagram SAP; for instance we need to keep track of the request 00044 * id. 00045 */ 00046 class TAO_RTEvent_Serv_Export TAO_ECG_UDP_Out_Endpoint 00047 { 00048 public: 00049 /// Constructor 00050 TAO_ECG_UDP_Out_Endpoint (void); 00051 00052 /// Constructor 00053 ~TAO_ECG_UDP_Out_Endpoint (void); 00054 00055 /// Copy Constructor 00056 TAO_ECG_UDP_Out_Endpoint (const TAO_ECG_UDP_Out_Endpoint& rhs); 00057 00058 /// Assignment operator 00059 TAO_ECG_UDP_Out_Endpoint& operator= (const TAO_ECG_UDP_Out_Endpoint& rhs); 00060 00061 /// Obtain the datagram associated with this endpoint. Clients of 00062 /// this class must open, and register (if necessary) this datagram. 00063 ACE_SOCK_Dgram& dgram (void); 00064 00065 /// Obtain the next request id. 00066 CORBA::ULong next_request_id (void); 00067 00068 /// The endpoint can detect if a data-gram was sent by itself, this 00069 /// is useful to ignore or remove messages sent by the same process. 00070 CORBA::Boolean is_loopback (const ACE_INET_Addr& from); 00071 00072 private: 00073 /// The request id.... 00074 ACE_Atomic_Op<TAO_SYNCH_MUTEX,CORBA::ULong> request_id_generator_; 00075 00076 /// The datagram.... 00077 ACE_SOCK_Dgram dgram_; 00078 00079 /// Cache the port-number so we can quickly determine if an event is 00080 /// coming from another endpoint. 00081 u_short port_number_; 00082 00083 /// Keep the list of local interfaces, needed for the is_loopback 00084 /// method. 00085 size_t if_count_; 00086 ACE_INET_Addr* ifs_; 00087 }; 00088 00089 /** 00090 * @typedef TAO_ECG_Refcounted_Endpoint 00091 * 00092 * @brief Reference counted pointer to TAO_ECG_UDP_Out_Endpoint 00093 * 00094 * Instances of TAO_ECG_UDP_Out_Endpoint are used by multiple objects 00095 * in the Event Channel gateways, the endpoints are reference counted 00096 * to manage their lifetime automatically. 00097 */ 00098 typedef ACE_Refcounted_Auto_Ptr<TAO_ECG_UDP_Out_Endpoint,ACE_Null_Mutex> TAO_ECG_Refcounted_Endpoint; 00099 00100 TAO_END_VERSIONED_NAMESPACE_DECL 00101 00102 #if defined(__ACE_INLINE__) 00103 #include "orbsvcs/Event/ECG_UDP_Out_Endpoint.i" 00104 #endif /* __ACE_INLINE__ */ 00105 00106 #include /**/ "ace/post.h" 00107 00108 #endif /* TAO_ECG_UDP_OUT_ENDPOINT_H */