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

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 Methods

 ACE_Name_Proxy (void)
 Default constructor. More...

 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. More...

int send_request (ACE_Name_Request &request)
 Perform the request. More...

int recv_reply (ACE_Name_Request &reply)
 Receive the reply. More...

virtual ACE_HANDLE get_handle (void) const
 Obtain underlying handle. More...

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

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


Private Attributes

ACE_SOCK_Connector connector_
 ACE_Connector factory used to establish connections actively. More...

ACE_SOCK_Stream peer_
 Connection to ACE_Name Server peer. More...

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


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 45 of file Name_Proxy.h.


Constructor & Destructor Documentation

ACE_Name_Proxy::ACE_Name_Proxy void   
 

Default constructor.

Definition at line 24 of file Name_Proxy.cpp.

References ACE_TRACE.

00025   : reactor_ (0)
00026 {
00027   ACE_TRACE ("ACE_Name_Proxy::ACE_Name_Proxy");
00028 }

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

Definition at line 50 of file Name_Proxy.cpp.

References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, EWOULDBLOCK, LM_ERROR, open, and ACE_Synch_Options::USE_TIMEOUT.

00052 {
00053   ACE_TRACE ("ACE_Name_Proxy::ACE_Name_Proxy");
00054   if (this->open (remote_addr, options) == -1
00055       && options[ACE_Synch_Options::USE_TIMEOUT] && errno != EWOULDBLOCK)
00056     ACE_ERROR ((LM_ERROR,
00057                 ACE_LIB_TEXT ("%p\n"),
00058                 ACE_LIB_TEXT ("ACE_Name_Proxy::ACE_Name_Proxy")));
00059 }

ACE_Name_Proxy::~ACE_Name_Proxy void    [virtual]
 

Close down the connection to the server.

Definition at line 198 of file Name_Proxy.cpp.

References ACE_TRACE, ACE_SOCK_Stream::close, and peer_.

00199 {
00200   ACE_TRACE ("ACE_Name_Proxy::~ACE_Name_Proxy");
00201   this->peer_.close ();
00202 }


Member Function Documentation

void ACE_Name_Proxy::dump void    const
 

Dump the state of the object;.

Definition at line 11 of file Name_Proxy.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, connector_, ACE_SOCK_Stream::dump, ACE_SOCK_Connector::dump, LM_DEBUG, and peer_.

Referenced by ACE_Remote_Name_Space::dump.

00012 {
00013   ACE_TRACE ("ACE_Name_Proxy::dump");
00014 
00015   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00016   this->connector_.dump ();
00017   this->peer_.dump ();
00018   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("reactor_ = %x"), this->reactor_));
00019   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00020 }

ACE_HANDLE ACE_Name_Proxy::get_handle void    const [virtual]
 

Obtain underlying handle.

Reimplemented from ACE_Event_Handler.

Definition at line 64 of file Name_Proxy.cpp.

References ACE_TRACE, ACE_IPC_SAP::get_handle, and peer_.

00065 {
00066   ACE_TRACE ("ACE_Name_Proxy::get_handle");
00067   return this->peer_.get_handle ();
00068 }

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

Definition at line 33 of file Name_Proxy.cpp.

References ACE_TRACE, ACE_SOCK_Connector::connect, connector_, ACE_Synch_Options::time_value, and ACE_Synch_Options::USE_TIMEOUT.

Referenced by ACE_Name_Proxy, and ACE_Remote_Name_Space::open.

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

int ACE_Name_Proxy::recv_reply ACE_Name_Request   reply
 

Receive the reply.

Definition at line 136 of file Name_Proxy.cpp.

References ACE_DEBUG, ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, ACE_Name_Request::decode, ACE_Name_Request::length, LM_DEBUG, LM_ERROR, peer_, 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.

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

int ACE_Name_Proxy::request_reply ACE_Name_Request   request
 

Perform the request and wait for the reply.

Definition at line 71 of file Name_Proxy.cpp.

References ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TRACE, ACE_Name_Reply::decode, ACE_Name_Request::encode, ACE_Name_Reply::errnum, LM_ERROR, peer_, ACE_SOCK_Stream::recv_n, ACE_SOCK_Stream::send_n, ssize_t, and ACE_Name_Reply::status.

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

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

int ACE_Name_Proxy::send_request ACE_Name_Request   request
 

Perform the request.

Definition at line 113 of file Name_Proxy.cpp.

References ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TRACE, ACE_Name_Request::encode, LM_ERROR, peer_, 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.

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


Member Data Documentation

ACE_SOCK_Connector ACE_Name_Proxy::connector_ [private]
 

ACE_Connector factory used to establish connections actively.

Definition at line 81 of file Name_Proxy.h.

Referenced by dump, and open.

ACE_SOCK_Stream ACE_Name_Proxy::peer_ [private]
 

Connection to ACE_Name Server peer.

Definition at line 84 of file Name_Proxy.h.

Referenced by dump, get_handle, recv_reply, request_reply, send_request, and ~ACE_Name_Proxy.

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 87 of file Name_Proxy.h.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:50:53 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002