#include <ECG_UDP_EH.h>
Inheritance diagram for TAO_ECG_UDP_EH:
Public Member Functions | |
virtual int | handle_input (ACE_HANDLE fd) |
ACE_SOCK_Dgram & | dgram (void) |
TAO_ECG_UDP_EH (TAO_ECG_Dgram_Handler *recv) | |
virtual | ~TAO_ECG_UDP_EH (void) |
Destructor. | |
int | open (const ACE_INET_Addr &ipaddr, int reuse_addr=0) |
virtual int | shutdown (void) |
Private Attributes | |
ACE_SOCK_Dgram | dgram_ |
The datagram used to receive the data. | |
TAO_ECG_Dgram_Handler * | receiver_ |
We callback to this object when a message arrives. |
Listens for messages on a UDP socket. When there is a message, calls handle_input () on a specified TAO_ECG_Dgram_Handler to inform it about message arrival.
NOT THREAD-SAFE.
Definition at line 43 of file ECG_UDP_EH.h.
|
Constructor. Messages received by this EH will be forwarded to the . Definition at line 15 of file ECG_UDP_EH.cpp. References ACE_ASSERT.
00016 : receiver_ (recv) 00017 { 00018 ACE_ASSERT (this->receiver_); 00019 } |
|
Destructor.
Definition at line 21 of file ECG_UDP_EH.cpp.
00022 { 00023 } |
|
Obtain the dgram, this is one of those "controlled violations of type safety", allowing the user to setup options and gain access to low-level features. Definition at line 8 of file ECG_UDP_EH.i.
00009 { 00010 return this->dgram_; 00011 } |
|
Main method - reactor callback. Notify that is ready for reading. Reimplemented from ACE_Event_Handler. Definition at line 82 of file ECG_UDP_EH.cpp. References TAO_ECG_Dgram_Handler::handle_input().
00083 { 00084 return this->receiver_->handle_input (this->dgram_); 00085 } |
|
Open the datagram and register itself with this->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 26 of file ECG_UDP_EH.cpp. References ACE_ERROR_RETURN, ACE_SOCK::close(), LM_ERROR, ACE_SOCK_Dgram::open(), ACE_Event_Handler::reactor(), and ACE_Reactor::register_handler(). Referenced by TAO_ECG_Mcast_Gateway::init_handler().
00028 { 00029 // Check that we haven't been closed already. 00030 if (!this->receiver_) 00031 return -1; 00032 00033 if (this->dgram_.open (ipaddr, PF_INET, 0, reuse_addr) == -1) 00034 ACE_ERROR_RETURN ((LM_ERROR, 00035 "Unable to open udp handler: " 00036 "error opening receiving dgram.\n"), 00037 -1); 00038 00039 if (!this->reactor () 00040 || 0 != this->reactor ()->register_handler (this->dgram_.get_handle (), 00041 this, 00042 ACE_Event_Handler::READ_MASK)) 00043 { 00044 this->dgram_.close (); 00045 ACE_ERROR_RETURN ((LM_ERROR, 00046 "Cannot register handler with reactor.\n"), 00047 -1); 00048 } 00049 00050 return 0; 00051 } |
|
TAO_ECG_Handler_Shutdown method. Unsubscribe from the reactor and close the datagram. Implements TAO_ECG_Handler_Shutdown. Definition at line 54 of file ECG_UDP_EH.cpp. References ACE_ERROR, ACE_SOCK::close(), LM_ERROR, ACE_Event_Handler::reactor(), and ACE_Reactor::remove_handler().
00055 { 00056 // Already shut down. 00057 if (!this->receiver_) 00058 return -1; 00059 00060 int result = 0; 00061 if (this->reactor ()) 00062 { 00063 result = this->reactor ()->remove_handler (this->dgram_.get_handle (), 00064 ACE_Event_Handler::READ_MASK); 00065 } 00066 if (result != 0) 00067 ACE_ERROR ((LM_ERROR, 00068 "Unable to deregister handler from reactor " 00069 "on shutdown.\n")); 00070 00071 result = this->dgram_.close (); 00072 if (result != 0) 00073 ACE_ERROR ((LM_ERROR, 00074 "Unable to close receiving dgram on shutdown.\n")); 00075 00076 this->receiver_ = 0; 00077 00078 return result; 00079 } |
|
The datagram used to receive the data.
Definition at line 88 of file ECG_UDP_EH.h. |
|
We callback to this object when a message arrives.
Definition at line 100 of file ECG_UDP_EH.h. |