ACE_Name_Proxy Class Reference

Proxy for dealing with remote server process managing NET_LOCAL NameBindings. More...

#include <Name_Proxy.h>

Inheritance diagram for ACE_Name_Proxy:

Inheritance graph
[legend]
Collaboration diagram for ACE_Name_Proxy:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_Name_Proxy (void)
 Default constructor.

 ACE_Name_Proxy (const ACE_INET_Addr &remote_addr, ACE_Synch_Options &options=ACE_Synch_Options::defaults)
int open (const ACE_INET_Addr &remote_addr, ACE_Synch_Options &options=ACE_Synch_Options::defaults)
int request_reply (ACE_Name_Request &request)
 Perform the request and wait for the reply.

int send_request (ACE_Name_Request &request)
 Perform the request.

int recv_reply (ACE_Name_Request &reply)
 Receive the reply.

virtual ACE_HANDLE get_handle (void) const
 Obtain underlying handle.

virtual ~ACE_Name_Proxy (void)
 Close down the connection to the server.

void dump (void) const
 Dump the state of the object;.


Private Member Functions

 ACE_Name_Proxy (const ACE_Name_Proxy &)
ACE_Name_Proxyoperator= (const ACE_Name_Proxy &)

Private Attributes

ACE_SOCK_Connector connector_
 ACE_Connector factory used to establish connections actively.

ACE_SOCK_Stream peer_
 Connection to ACE_Name Server peer.

ACE_Reactorreactor_
 Pointer to ACE_Reactor (used if we are run in "reactive-mode").


Detailed Description

Proxy for dealing with remote server process managing NET_LOCAL NameBindings.

Shields applications from details of interacting with the ACE_Name Server.

Definition at line 48 of file Name_Proxy.h.


Constructor & Destructor Documentation

ACE_Name_Proxy::ACE_Name_Proxy void   ) 
 

Default constructor.

Definition at line 27 of file Name_Proxy.cpp.

References ACE_TRACE.

00028   : reactor_ (0)
00029 {
00030   ACE_TRACE ("ACE_Name_Proxy::ACE_Name_Proxy");
00031 }

ACE_Name_Proxy::ACE_Name_Proxy const ACE_INET_Addr remote_addr,
ACE_Synch_Options options = ACE_Synch_Options::defaults
 

Definition at line 53 of file Name_Proxy.cpp.

References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, EWOULDBLOCK, LM_ERROR, and open().

00056    : reactor_ (0)
00057 {
00058   ACE_TRACE ("ACE_Name_Proxy::ACE_Name_Proxy");
00059   if (this->open (remote_addr, options) == -1
00060       && options[ACE_Synch_Options::USE_TIMEOUT] && errno != EWOULDBLOCK)
00061     ACE_ERROR ((LM_ERROR,
00062                 ACE_LIB_TEXT ("%p\n"),
00063                 ACE_LIB_TEXT ("ACE_Name_Proxy::ACE_Name_Proxy")));
00064 }

ACE_Name_Proxy::~ACE_Name_Proxy void   )  [virtual]
 

Close down the connection to the server.

Definition at line 203 of file Name_Proxy.cpp.

References ACE_TRACE, and ACE_SOCK_Stream::close().

00204 {
00205   ACE_TRACE ("ACE_Name_Proxy::~ACE_Name_Proxy");
00206   this->peer_.close ();
00207 }

ACE_Name_Proxy::ACE_Name_Proxy const ACE_Name_Proxy  )  [private]
 


Member Function Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL void ACE_Name_Proxy::dump void   )  const
 

Dump the state of the object;.

Definition at line 12 of file Name_Proxy.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, ACE_SOCK_Stream::dump(), ACE_SOCK_Connector::dump(), and LM_DEBUG.

Referenced by ACE_Remote_Name_Space::dump().

00013 {
00014 #if defined (ACE_HAS_DUMP)
00015   ACE_TRACE ("ACE_Name_Proxy::dump");
00016 
00017   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00018   this->connector_.dump ();
00019   this->peer_.dump ();
00020   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("reactor_ = %x"), this->reactor_));
00021   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00022 #endif /* ACE_HAS_DUMP */
00023 }

ACE_HANDLE ACE_Name_Proxy::get_handle void   )  const [virtual]
 

Obtain underlying handle.

Reimplemented from ACE_Event_Handler.

Definition at line 69 of file Name_Proxy.cpp.

References ACE_TRACE, and ACE_IPC_SAP::get_handle().

00070 {
00071   ACE_TRACE ("ACE_Name_Proxy::get_handle");
00072   return this->peer_.get_handle ();
00073 }

int ACE_Name_Proxy::open const ACE_INET_Addr remote_addr,
ACE_Synch_Options options = ACE_Synch_Options::defaults
 

Definition at line 36 of file Name_Proxy.cpp.

References ACE_TRACE, ACE_SOCK_Connector::connect(), and ACE_Synch_Options::time_value().

Referenced by ACE_Name_Proxy(), and ACE_Remote_Name_Space::open().

00038 {
00039   ACE_TRACE ("ACE_Name_Proxy::open");
00040   ACE_Time_Value *timeout = 0;
00041 
00042   if (options[ACE_Synch_Options::USE_TIMEOUT])
00043     timeout = const_cast<ACE_Time_Value *> (options.time_value ());
00044 
00045   // Initiate the connection.
00046   return this->connector_.connect (this->peer_,
00047                                    remote_addr,
00048                                    timeout);
00049 }

ACE_Name_Proxy& ACE_Name_Proxy::operator= const ACE_Name_Proxy  )  [private]
 

int ACE_Name_Proxy::recv_reply ACE_Name_Request reply  ) 
 

Receive the reply.

Definition at line 141 of file Name_Proxy.cpp.

References ACE_DEBUG, ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, LM_DEBUG, LM_ERROR, ACE_SOCK_IO::recv(), and ssize_t.

Referenced by ACE_Remote_Name_Space::list_name_entries(), ACE_Remote_Name_Space::list_names(), ACE_Remote_Name_Space::list_type_entries(), ACE_Remote_Name_Space::list_types(), ACE_Remote_Name_Space::list_value_entries(), ACE_Remote_Name_Space::list_values(), and ACE_Remote_Name_Space::resolve().

00142 {
00143   ACE_TRACE ("ACE_Name_Proxy::recv_reply");
00144   // Read the first 4 bytes to get the length of the message This
00145   // implementation assumes that the first 4 bytes are the length of
00146   // the message.
00147   ssize_t n = this->peer_.recv ((void *) &reply, sizeof (ACE_UINT32));
00148 
00149   switch (n)
00150     {
00151     case -1:
00152       // FALLTHROUGH
00153       ACE_DEBUG ((LM_DEBUG,
00154                   ACE_LIB_TEXT ("****************** recv_reply returned -1\n")));
00155     default:
00156       ACE_ERROR ((LM_ERROR,
00157                   ACE_LIB_TEXT ("%p got %d bytes, expected %d bytes\n"),
00158                   ACE_LIB_TEXT ("recv failed"),
00159                   n,
00160                   sizeof (ACE_UINT32)));
00161       // FALLTHROUGH
00162     case 0:
00163       // We've shutdown unexpectedly
00164       return -1;
00165       // NOTREACHED
00166     case sizeof (ACE_UINT32):
00167       {
00168         // Transform the length into host byte order.
00169         ssize_t length = ntohl (reply.length ());
00170 
00171         // Receive the rest of the request message.
00172         // @@ beware of blocking read!!!.
00173         n = this->peer_.recv ((void *) (((char *) &reply)
00174                                         + sizeof (ACE_UINT32)),
00175                               length - sizeof (ACE_UINT32));
00176 
00177         // Subtract off the size of the part we skipped over...
00178         if (n != ssize_t (length - sizeof (ACE_UINT32)))
00179           {
00180             ACE_ERROR ((LM_ERROR,
00181                         ACE_LIB_TEXT ("%p expected %d, got %d\n"),
00182                         ACE_LIB_TEXT ("invalid length"),
00183                         length,
00184                         n));
00185             return -1;
00186           }
00187 
00188         // Decode the request into host byte order.
00189         if (reply.decode () == -1)
00190           {
00191             ACE_ERROR ((LM_ERROR,
00192                         ACE_LIB_TEXT ("%p\n"),
00193                         ACE_LIB_TEXT ("decode failed")));
00194             return -1;
00195           }
00196       }
00197     }
00198   return 0;
00199 }

int ACE_Name_Proxy::request_reply ACE_Name_Request request  ) 
 

Perform the request and wait for the reply.

Definition at line 76 of file Name_Proxy.cpp.

References ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TRACE, ACE_Name_Request::encode(), LM_ERROR, ACE_SOCK_Stream::recv_n(), ACE_SOCK_Stream::send_n(), and ssize_t.

Referenced by ACE_Remote_Name_Space::bind(), ACE_Remote_Name_Space::rebind(), and ACE_Remote_Name_Space::unbind().

00077 {
00078   ACE_TRACE ("ACE_Name_Proxy::request_reply");
00079   void *buffer;
00080   ssize_t length = request.encode (buffer);
00081 
00082   if (length == -1)
00083     ACE_ERROR_RETURN ((LM_ERROR,
00084                        ACE_LIB_TEXT ("%p\n"),
00085                        ACE_LIB_TEXT ("encode failed")),
00086                       -1);
00087 
00088   // Transmit request via a blocking send.
00089 
00090   if (this->peer_.send_n (buffer, length) != length)
00091     ACE_ERROR_RETURN ((LM_ERROR,
00092                        ACE_LIB_TEXT ("%p\n"),
00093                        ACE_LIB_TEXT ("send_n failed")),
00094                       -1);
00095   else
00096     {
00097       ACE_Name_Reply reply;
00098 
00099       // Receive reply via blocking read.
00100 
00101       if (this->peer_.recv_n (&reply,
00102                               sizeof reply) == -1)
00103         ACE_ERROR_RETURN ((LM_ERROR,
00104                            ACE_LIB_TEXT ("%p\n"),
00105                            ACE_LIB_TEXT ("recv failed")),
00106                           -1);
00107       else if (reply.decode () == -1)
00108         ACE_ERROR_RETURN ((LM_ERROR,
00109                            ACE_LIB_TEXT ("%p\n"),
00110                            ACE_LIB_TEXT ("decode failed")),
00111                           -1);
00112       errno = int (reply.errnum ());
00113       return reply.status ();
00114     }
00115 }

int ACE_Name_Proxy::send_request ACE_Name_Request request  ) 
 

Perform the request.

Definition at line 118 of file Name_Proxy.cpp.

References ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TRACE, ACE_Name_Request::encode(), LM_ERROR, ACE_SOCK_Stream::send_n(), and ssize_t.

Referenced by ACE_Remote_Name_Space::list_name_entries(), ACE_Remote_Name_Space::list_names(), ACE_Remote_Name_Space::list_type_entries(), ACE_Remote_Name_Space::list_types(), ACE_Remote_Name_Space::list_value_entries(), ACE_Remote_Name_Space::list_values(), and ACE_Remote_Name_Space::resolve().

00119 {
00120   ACE_TRACE ("ACE_Name_Proxy::send_request");
00121   void *buffer;
00122   ssize_t length = request.encode (buffer);
00123 
00124   if (length == -1)
00125     ACE_ERROR_RETURN ((LM_ERROR,
00126                        ACE_LIB_TEXT ("%p\n"),
00127                        ACE_LIB_TEXT ("encode failed")),
00128                       -1);
00129 
00130   // Transmit request via a blocking send.
00131 
00132   else if (this->peer_.send_n (buffer, length) != length)
00133     ACE_ERROR_RETURN ((LM_ERROR,
00134                        ACE_LIB_TEXT ("%p\n"),
00135                        ACE_LIB_TEXT ("send_n failed")),
00136                       -1);
00137   return 0;
00138 }


Member Data Documentation

ACE_SOCK_Connector ACE_Name_Proxy::connector_ [private]
 

ACE_Connector factory used to establish connections actively.

Definition at line 84 of file Name_Proxy.h.

ACE_SOCK_Stream ACE_Name_Proxy::peer_ [private]
 

Connection to ACE_Name Server peer.

Definition at line 87 of file Name_Proxy.h.

ACE_Reactor* ACE_Name_Proxy::reactor_ [private]
 

Pointer to ACE_Reactor (used if we are run in "reactive-mode").

Reimplemented from ACE_Event_Handler.

Definition at line 90 of file Name_Proxy.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:25:28 2006 for ACE by doxygen 1.3.6