#include <ECG_Simple_Mcast_EH.h>
Inheritance diagram for TAO_ECG_Simple_Mcast_EH:
Public Member Functions | |
virtual int | handle_input (ACE_HANDLE fd) |
TAO_ECG_Simple_Mcast_EH (TAO_ECG_Dgram_Handler *recv) | |
virtual | ~TAO_ECG_Simple_Mcast_EH (void) |
Destructor. | |
int | open (const char *mcast_addr, const ACE_TCHAR *net_if=0) |
virtual int | shutdown (void) |
Private Attributes | |
ACE_SOCK_Dgram_Mcast | dgram_ |
TAO_ECG_Dgram_Handler * | receiver_ |
We callback to this object when a message arrives. |
NOT THREAD-SAFE.
Definition at line 39 of file ECG_Simple_Mcast_EH.h.
|
Constructor. Messages received by this EH will be forwarded to the . Definition at line 10 of file ECG_Simple_Mcast_EH.cpp. References ACE_ASSERT.
00011 : receiver_ (recv) 00012 { 00013 ACE_ASSERT (this->receiver_); 00014 } |
|
Destructor.
Definition at line 16 of file ECG_Simple_Mcast_EH.cpp.
00017 { 00018 } |
|
Main method - reactor callback. Notify that is ready for reading. Reimplemented from ACE_Event_Handler. Definition at line 93 of file ECG_Simple_Mcast_EH.cpp. References TAO_ECG_Dgram_Handler::handle_input().
00094 { 00095 return this->receiver_->handle_input (this->dgram_); 00096 } |
|
Join the specified multicast group and register itself with the reactor. To insure proper resource clean up, if open () is successful, the user MUST call shutdown () when handler is no longer needed (and its reactor still exists). Definition at line 21 of file ECG_Simple_Mcast_EH.cpp. References ACE_ERROR_RETURN, ACE_NONBLOCK, ACE_SOCK::close(), dgram_, ACE_IPC_SAP::enable(), LM_ERROR, ACE_Event_Handler::reactor(), ACE_Reactor::register_handler(), ACE_INET_Addr::set(), and ACE_SOCK_Dgram_Mcast::subscribe(). Referenced by TAO_ECG_Mcast_Gateway::init_handler().
00023 { 00024 // Check that we haven't been closed already. 00025 if (!this->receiver_) 00026 return -1; 00027 00028 if (mcast_addr == 0) 00029 return -1; 00030 00031 ACE_INET_Addr mcast_group; 00032 if (mcast_group.set (mcast_addr) != 0) 00033 ACE_ERROR_RETURN ((LM_ERROR, 00034 "Unable to open mcast handler: " 00035 "error using specified address %s " 00036 "in ACE_INET.set ().\n", 00037 mcast_addr), 00038 -1); 00039 00040 if (this->dgram_.subscribe (mcast_group, 1, net_if) != 0) 00041 ACE_ERROR_RETURN ((LM_ERROR, 00042 "Unable to open mcast handler: error " 00043 "subscribing to %s\n", 00044 mcast_addr), 00045 -1); 00046 00047 (void) dgram_.enable(ACE_NONBLOCK); 00048 00049 if (!this->reactor () 00050 || 0 != this->reactor ()->register_handler (this->dgram_.get_handle (), 00051 this, 00052 ACE_Event_Handler::READ_MASK)) 00053 { 00054 this->dgram_.close (); 00055 ACE_ERROR_RETURN ((LM_ERROR, 00056 "Cannot register handler with reactor.\n"), 00057 -1); 00058 } 00059 00060 return 0; 00061 } |
|
TAO_ECG_Handler_Shutdown method. Unsubscribe from the reactor and close the datagram. Implements TAO_ECG_Handler_Shutdown. Definition at line 64 of file ECG_Simple_Mcast_EH.cpp. References ACE_ERROR, ACE_SOCK::close(), dgram_, LM_ERROR, ACE_Event_Handler::reactor(), and ACE_Reactor::remove_handler().
00065 { 00066 // Already shut down. 00067 if (!this->receiver_) 00068 return -1; 00069 00070 int result = 0; 00071 if (this->reactor ()) 00072 { 00073 result = this->reactor ()->remove_handler (this->dgram_.get_handle (), 00074 ACE_Event_Handler::READ_MASK); 00075 } 00076 if (result != 0) 00077 ACE_ERROR ((LM_ERROR, 00078 "Unable to deregister handler from reactor " 00079 "on shutdown.\n")); 00080 00081 result = this->dgram_.close (); 00082 if (result != 0) 00083 ACE_ERROR ((LM_ERROR, 00084 "Unable to close mcast receiving dgram " 00085 "on shutdown.\n")); 00086 00087 this->receiver_ = 0; 00088 00089 return result; 00090 } |
|
Definition at line 78 of file ECG_Simple_Mcast_EH.h. Referenced by open(), and shutdown(). |
|
We callback to this object when a message arrives.
Definition at line 90 of file ECG_Simple_Mcast_EH.h. |