Defines an active connection factory for ACE_SPIPE_Stream. On Windows this is mapped to Named Pipes, whereas on UNIX it is mapped to STREAM pipes. More...
#include <SPIPE_Connector.h>
Public Types | |
| typedef ACE_SPIPE_Addr | PEER_ADDR |
| typedef ACE_SPIPE_Stream | PEER_STREAM |
Public Member Functions | |
| ACE_SPIPE_Connector (void) | |
| Default constructor. | |
| ACE_SPIPE_Connector (ACE_SPIPE_Stream &new_io, const ACE_SPIPE_Addr &remote_sap, ACE_Time_Value *timeout=0, const ACE_Addr &local_sap=ACE_Addr::sap_any, int reuse_addr=0, int flags=O_RDWR, int perms=0, LPSECURITY_ATTRIBUTES sa=0, int pipe_mode=PIPE_READMODE_MESSAGE|PIPE_WAIT) | |
| int | connect (ACE_SPIPE_Stream &new_io, const ACE_SPIPE_Addr &remote_sap, ACE_Time_Value *timeout=0, const ACE_Addr &local_sap=ACE_Addr::sap_any, int reuse_addr=0, int flags=O_RDWR, int perms=0, LPSECURITY_ATTRIBUTES sa=0, int pipe_mode=PIPE_READMODE_MESSAGE|PIPE_WAIT) |
| bool | reset_new_handle (ACE_HANDLE handle) |
| Resets any event associations on this handle. | |
| void | dump (void) const |
| Dump the state of an object. | |
Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. | |
Defines an active connection factory for ACE_SPIPE_Stream. On Windows this is mapped to Named Pipes, whereas on UNIX it is mapped to STREAM pipes.
Definition at line 34 of file SPIPE_Connector.h.
Definition at line 101 of file SPIPE_Connector.h.
Definition at line 102 of file SPIPE_Connector.h.
| ACE_SPIPE_Connector::ACE_SPIPE_Connector | ( | void | ) |
Default constructor.
Definition at line 47 of file SPIPE_Connector.cpp.
{
ACE_TRACE ("ACE_SPIPE_Connector::ACE_SPIPE_Connector");
}
| ACE_SPIPE_Connector::ACE_SPIPE_Connector | ( | ACE_SPIPE_Stream & | new_io, | |
| const ACE_SPIPE_Addr & | remote_sap, | |||
| ACE_Time_Value * | timeout = 0, |
|||
| const ACE_Addr & | local_sap = ACE_Addr::sap_any, |
|||
| int | reuse_addr = 0, |
|||
| int | flags = O_RDWR, |
|||
| int | perms = 0, |
|||
| LPSECURITY_ATTRIBUTES | sa = 0, |
|||
| int | pipe_mode = PIPE_READMODE_MESSAGE | PIPE_WAIT | |||
| ) |
Actively connect and produce a <new_stream> if things go well. The remote_sap is the address that we are trying to connect with. The timeout is the amount of time to wait to connect. If it's 0 then we block indefinitely. If *timeout == {0, 0} then the connection is done using non-blocking mode. In this case, if the connection can't be made immediately the value of -1 is returned with errno == EWOULDBLOCK. If *timeout > {0, 0} then this is the maximum amount of time to wait before timing out. If the time expires before the connection is made errno == ETIME. The local_sap is the value of local address to bind to. If it's the default value of ACE_Addr::sap_any then the user is letting the OS do the binding. If reuse_addr == 1 then the <local_addr> is reused, even if it hasn't been cleanedup yet. The flags and perms arguments are passed down to the <open> method. The pipe_mode argument is only used in NT and is used to establish the NT pipe mode.
Definition at line 21 of file SPIPE_Connector.cpp.
{
ACE_TRACE ("ACE_SPIPE_Connector::ACE_SPIPE_Connector");
if (this->connect (new_io, remote_sap, timeout, local_sap,
reuse_addr, flags, perms, sa, pipe_mode) == -1
&& timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME))
ACE_ERROR ((LM_ERROR, ACE_TEXT ("address %s, %p\n"),
remote_sap.get_path_name (), ACE_TEXT ("ACE_SPIPE_Connector")));
}
| int ACE_SPIPE_Connector::connect | ( | ACE_SPIPE_Stream & | new_io, | |
| const ACE_SPIPE_Addr & | remote_sap, | |||
| ACE_Time_Value * | timeout = 0, |
|||
| const ACE_Addr & | local_sap = ACE_Addr::sap_any, |
|||
| int | reuse_addr = 0, |
|||
| int | flags = O_RDWR, |
|||
| int | perms = 0, |
|||
| LPSECURITY_ATTRIBUTES | sa = 0, |
|||
| int | pipe_mode = PIPE_READMODE_MESSAGE | PIPE_WAIT | |||
| ) |
Actively connect and produce a <new_stream> if things go well. The remote_sap is the address that we are trying to connect with. The timeout is the amount of time to wait to connect. If it's 0 then we block indefinitely. If *timeout == {0, 0} then the connection is done using non-blocking mode. In this case, if the connection can't be made immediately the value of -1 is returned with errno == EWOULDBLOCK. If *timeout > {0, 0} then this is the maximum amount of time to wait before timing out. If the time expires before the connection is made errno == ETIME. The local_sap is the value of local address to bind to. If it's the default value of ACE_Addr::sap_any then the user is letting the OS do the binding. If reuse_addr == 1 then the <local_addr> is reused, even if it hasn't been cleanedup yet. The flags and perms arguments are passed down to the <open> method. The pipe_mode argument is only used in NT and is used to establish the NT pipe mode.
Definition at line 53 of file SPIPE_Connector.cpp.
{
ACE_TRACE ("ACE_SPIPE_Connector::connect");
// Make darn sure that the O_CREAT flag is not set!
ACE_CLR_BITS (flags, O_CREAT);
ACE_HANDLE handle;
ACE_UNUSED_ARG (pipe_mode);
#if defined (ACE_WIN32) && \
!defined (ACE_HAS_PHARLAP) && !defined (ACE_HAS_WINCE)
// We need to allow for more than one attempt to connect,
// calculate the absolute time at which we give up.
ACE_Time_Value absolute_time;
if (timeout != 0)
absolute_time = ACE_OS::gettimeofday () + *timeout;
// Loop until success or failure.
for (;;)
{
handle = ACE_OS::open (remote_sap.get_path_name(), flags, perms, sa);
if (handle != ACE_INVALID_HANDLE)
// Success!
break;
// Check if we have a busy pipe condition.
if (::GetLastError() != ERROR_PIPE_BUSY)
// Nope, this is a failure condition.
break;
// This will hold the time out value used in the ::WaitNamedPipe
// call.
DWORD time_out_value;
// Check if we are to block until we connect.
if (timeout == 0)
// Wait for as long as it takes.
time_out_value = NMPWAIT_WAIT_FOREVER;
else
{
// Calculate the amount of time left to wait.
ACE_Time_Value relative_time (absolute_time - ACE_OS::gettimeofday ());
// Check if we have run out of time.
if (relative_time <= ACE_Time_Value::zero)
{
// Mimick the errno value returned by
// ACE::handle_timed_open.
if (*timeout == ACE_Time_Value::zero)
errno = EWOULDBLOCK;
else
errno = ETIMEDOUT;
// Exit the connect loop with the failure.
break;
}
// Get the amount of time remaining for ::WaitNamedPipe.
time_out_value = relative_time.msec ();
}
// Wait for the named pipe to become available.
ACE_TEXT_WaitNamedPipe (remote_sap.get_path_name (),
time_out_value);
// Regardless of the return value, we'll do one more attempt to
// connect to see if it is now available and to return
// consistent error values.
}
// Set named pipe mode if we have a valid handle.
if (handle != ACE_INVALID_HANDLE)
{
// Check if we are changing the pipe mode from the default.
if (pipe_mode != (PIPE_READMODE_BYTE | PIPE_WAIT))
{
DWORD dword_pipe_mode = pipe_mode;
if (!::SetNamedPipeHandleState (handle,
&dword_pipe_mode,
0,
0))
{
// We were not able to put the pipe into the requested
// mode.
ACE_OS::close (handle);
handle = ACE_INVALID_HANDLE;
}
}
}
#else /* ACE_WIN32 && !ACE_HAS_PHARLAP */
handle = ACE::handle_timed_open (timeout,
remote_sap.get_path_name (),
flags, perms, sa);
#endif /* !ACE_WIN32 || ACE_HAS_PHARLAP || ACE_HAS_WINCE */
new_io.set_handle (handle);
new_io.remote_addr_ = remote_sap; // class copy.
return handle == ACE_INVALID_HANDLE ? -1 : 0;
}
| void ACE_SPIPE_Connector::dump | ( | void | ) | const |
Dump the state of an object.
Definition at line 40 of file SPIPE_Connector.cpp.
{
#if defined (ACE_HAS_DUMP)
ACE_TRACE ("ACE_SPIPE_Connector::dump");
#endif /* ACE_HAS_DUMP */
}
| bool ACE_SPIPE_Connector::reset_new_handle | ( | ACE_HANDLE | handle | ) |
Resets any event associations on this handle.
Definition at line 8 of file SPIPE_Connector.inl.
{
// Nothing to do here since the handle is not a socket
return false;
}
Declare the dynamic allocation hooks.
Definition at line 108 of file SPIPE_Connector.h.
1.7.0