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

ACE_UPIPE_Connector Class Reference

Defines an active connection factory for the ACE_UPIPE_STREAM wrappers. More...

#include <UPIPE_Connector.h>

List of all members.

Public Types

typedef ACE_UPIPE_Addr PEER_ADDR
typedef ACE_UPIPE_Stream PEER_STREAM

Public Methods

 ACE_UPIPE_Connector (void)
 Default constructor. More...

 ACE_UPIPE_Connector (ACE_UPIPE_Stream &new_stream, const ACE_UPIPE_Addr &addr, 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)
int connect (ACE_UPIPE_Stream &new_stream, const ACE_UPIPE_Addr &addr, 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)
int reset_new_handle (ACE_HANDLE handle)
 Resets any event associations on this handle. More...

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


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Detailed Description

Defines an active connection factory for the ACE_UPIPE_STREAM wrappers.

Definition at line 35 of file UPIPE_Connector.h.


Member Typedef Documentation

typedef ACE_UPIPE_Addr ACE_UPIPE_Connector::PEER_ADDR
 

Definition at line 96 of file UPIPE_Connector.h.

typedef ACE_UPIPE_Stream ACE_UPIPE_Connector::PEER_STREAM
 

Definition at line 97 of file UPIPE_Connector.h.


Constructor & Destructor Documentation

ACE_UPIPE_Connector::ACE_UPIPE_Connector void   
 

Default constructor.

Definition at line 23 of file UPIPE_Connector.cpp.

References ACE_TRACE.

00024 {
00025   ACE_TRACE ("ACE_UPIPE_Connector::ACE_UPIPE_Connector");
00026 }

ASYS_INLINE ACE_UPIPE_Connector::ACE_UPIPE_Connector ACE_UPIPE_Stream   new_stream,
const ACE_UPIPE_Addr   addr,
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
 

Actively connect and produce a new_stream if things go well. The addr 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.

Definition at line 9 of file UPIPE_Connector.i.

References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, connect, ETIME, EWOULDBLOCK, ACE_SPIPE_Addr::get_path_name, and LM_ERROR.

00016 {
00017   ACE_TRACE ("ACE_UPIPE_Connector::ACE_UPIPE_Connector");
00018   if (this->connect (new_stream, addr, timeout, local_sap,
00019                      reuse_addr, flags, perms) == -1
00020       && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME))
00021     ACE_ERROR ((LM_ERROR,
00022                 ACE_LIB_TEXT ("address %s, %p\n"),
00023                 addr.get_path_name (),
00024                 ACE_LIB_TEXT ("ACE_UPIPE_Connector")));
00025 }


Member Function Documentation

int ACE_UPIPE_Connector::connect ACE_UPIPE_Stream   new_stream,
const ACE_UPIPE_Addr   addr,
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
 

Actively connect and produce a new_stream if things go well. The addr 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.

Definition at line 29 of file UPIPE_Connector.cpp.

References ACE_ASSERT, ACE_ERROR, ACE_GUARD_RETURN, ACE_LIB_TEXT, ACE_MT, ACE_TRACE, ACE_UPIPE_Stream::get_handle, ACE_SPIPE_Addr::get_path_name, ACE_Handle_Ops::handle_timed_open, ACE_OS::isastream, LM_ERROR, ACE_UPIPE_Stream::recv, ACE_UPIPE_Stream::reference_count_, ACE_UPIPE_Stream::remote_addr_, ACE_IPC_SAP::set_handle, ssize_t, and ACE_OS::write.

Referenced by ACE_UPIPE_Connector.

00036 {
00037   ACE_TRACE ("ACE_UPIPE_Connector::connect");
00038   ACE_ASSERT (new_stream.get_handle () == ACE_INVALID_HANDLE);
00039 
00040   ACE_HANDLE handle = ACE_Handle_Ops::handle_timed_open (timeout,
00041                                                          addr.get_path_name (),
00042                                                          flags, perms);
00043 
00044   if (handle == ACE_INVALID_HANDLE)
00045     return -1;
00046 #if !defined (ACE_WIN32)
00047   else if (ACE_OS::isastream (handle) != 1)
00048     return -1;
00049 #endif
00050   else // We're connected!
00051     {
00052       ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, new_stream.lock_, -1));
00053 
00054       ACE_UPIPE_Stream *ustream = &new_stream;
00055 
00056       new_stream.set_handle (handle);
00057       new_stream.remote_addr_ = addr; // class copy.
00058       new_stream.reference_count_++;
00059 
00060       // Now send the address of our ACE_UPIPE_Stream over this pipe
00061       // to our corresponding ACE_UPIPE_Acceptor, so he may link the
00062       // two streams.
00063       ssize_t result = ACE_OS::write (handle,
00064                                       (const char *) &ustream,
00065                                       sizeof ustream);
00066       if (result == -1)
00067         ACE_ERROR ((LM_ERROR,
00068                     ACE_LIB_TEXT ("ACE_UPIPE_Connector %p\n"),
00069                     ACE_LIB_TEXT ("write to pipe failed")));
00070 
00071       // Wait for confirmation of stream linking.
00072       ACE_Message_Block *mb_p = 0;
00073 
00074       // Our part is done, wait for server to confirm connection.
00075       result = new_stream.recv (mb_p, 0);
00076 
00077       // Do *not* coalesce the following two checks for result == -1.
00078       // They perform different checks and cannot be merged.
00079       if (result == -1)
00080           ACE_ERROR ((LM_ERROR,
00081                       ACE_LIB_TEXT ("ACE_UPIPE_Connector %p\n"),
00082                       ACE_LIB_TEXT ("no confirmation from server")));
00083       else
00084         // Close down the new_stream at this point in order to
00085         // conserve handles.  Note that we don't need the SPIPE
00086         // connection anymore since we're linked via the Message_Queue
00087         // now.
00088         new_stream.ACE_SPIPE::close ();
00089       return result;
00090     }
00091 }

void ACE_UPIPE_Connector::dump void    const
 

Dump the state of an object.

Definition at line 18 of file UPIPE_Connector.cpp.

References ACE_TRACE.

00019 {
00020   ACE_TRACE ("ACE_UPIPE_Connector::dump");
00021 }

ASYS_INLINE int ACE_UPIPE_Connector::reset_new_handle ACE_HANDLE    handle
 

Resets any event associations on this handle.

Definition at line 28 of file UPIPE_Connector.i.

00029 {
00030   ACE_UNUSED_ARG (handle);
00031   // Nothing to do here since the handle is not a socket
00032   return 0;
00033 }


Member Data Documentation

ACE_UPIPE_Connector::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 103 of file UPIPE_Connector.h.


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