Proxy for dealing with remote server process managing NET_LOCAL NameBindings. More...
#include <Name_Proxy.h>


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_Proxy & | operator= (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_Reactor * | reactor_ |
| Pointer to ACE_Reactor (used if we are run in "reactive-mode"). | |
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.
| ACE_Name_Proxy::ACE_Name_Proxy | ( | void | ) |
Default constructor.
Definition at line 27 of file Name_Proxy.cpp.
| 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.
| ACE_Name_Proxy::~ACE_Name_Proxy | ( | void | ) | [virtual] |
Close down the connection to the server.
Definition at line 203 of file Name_Proxy.cpp.
| ACE_Name_Proxy::ACE_Name_Proxy | ( | const ACE_Name_Proxy & | ) | [private] |
| void ACE_Name_Proxy::dump | ( | void | ) | const |
Dump the state of the object;.
Definition at line 12 of file Name_Proxy.cpp.
{
#if defined (ACE_HAS_DUMP)
ACE_TRACE ("ACE_Name_Proxy::dump");
ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
this->connector_.dump ();
this->peer_.dump ();
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("reactor_ = %x"), this->reactor_));
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
#endif /* ACE_HAS_DUMP */
}
| 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.
{
ACE_TRACE ("ACE_Name_Proxy::get_handle");
return this->peer_.get_handle ();
}
| 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.
{
ACE_TRACE ("ACE_Name_Proxy::open");
ACE_Time_Value *timeout = 0;
if (options[ACE_Synch_Options::USE_TIMEOUT])
timeout = const_cast<ACE_Time_Value *> (options.time_value ());
// Initiate the connection.
return this->connector_.connect (this->peer_,
remote_addr,
timeout);
}
| 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.
{
ACE_TRACE ("ACE_Name_Proxy::recv_reply");
// Read the first 4 bytes to get the length of the message This
// implementation assumes that the first 4 bytes are the length of
// the message.
ssize_t n = this->peer_.recv ((void *) &reply, sizeof (ACE_UINT32));
switch (n)
{
case -1:
// FALLTHROUGH
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("****************** recv_reply returned -1\n")));
default:
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p got %d bytes, expected %d bytes\n"),
ACE_TEXT ("recv failed"),
n,
sizeof (ACE_UINT32)));
// FALLTHROUGH
case 0:
// We've shutdown unexpectedly
return -1;
// NOTREACHED
case sizeof (ACE_UINT32):
{
// Transform the length into host byte order.
ssize_t length = ACE_NTOHL (reply.length ());
// Receive the rest of the request message.
// @@ beware of blocking read!!!.
n = this->peer_.recv ((void *) (((char *) &reply)
+ sizeof (ACE_UINT32)),
length - sizeof (ACE_UINT32));
// Subtract off the size of the part we skipped over...
if (n != ssize_t (length - sizeof (ACE_UINT32)))
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p expected %d, got %d\n"),
ACE_TEXT ("invalid length"),
length,
n));
return -1;
}
// Decode the request into host byte order.
if (reply.decode () == -1)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("decode failed")));
return -1;
}
}
}
return 0;
}
| 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.
{
ACE_TRACE ("ACE_Name_Proxy::request_reply");
void *buffer;
ssize_t length = request.encode (buffer);
if (length == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("encode failed")),
-1);
// Transmit request via a blocking send.
if (this->peer_.send_n (buffer, length) != length)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("send_n failed")),
-1);
else
{
ACE_Name_Reply reply;
// Receive reply via blocking read.
if (this->peer_.recv_n (&reply,
sizeof reply) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("recv failed")),
-1);
else if (reply.decode () == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("decode failed")),
-1);
errno = int (reply.errnum ());
return reply.status ();
}
}
| int ACE_Name_Proxy::send_request | ( | ACE_Name_Request & | request | ) |
Perform the request.
Definition at line 118 of file Name_Proxy.cpp.
{
ACE_TRACE ("ACE_Name_Proxy::send_request");
void *buffer;
ssize_t length = request.encode (buffer);
if (length == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("encode failed")),
-1);
// Transmit request via a blocking send.
else if (this->peer_.send_n (buffer, length) != length)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("send_n failed")),
-1);
return 0;
}
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.
1.7.0