ACE_UPIPE_Acceptor Class Reference

Defines the format and interface for the listener side of the ACE_UPIPE_Stream. More...

#include <UPIPE_Acceptor.h>

Inheritance diagram for ACE_UPIPE_Acceptor:

Inheritance graph
[legend]
Collaboration diagram for ACE_UPIPE_Acceptor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_UPIPE_Acceptor (void)
 Default constructor.

 ACE_UPIPE_Acceptor (const ACE_UPIPE_Addr &local_sap, int reuse_addr=0)
 Initialize passive endpoint.

int open (const ACE_UPIPE_Addr &local_sap, int reuse_addr=0)
 Initialize passive endpoint.

 ~ACE_UPIPE_Acceptor (void)
 Close down and release resources.

int close (void)
 Close down and release resources.

int remove (void)
int accept (ACE_UPIPE_Stream &server_stream, ACE_UPIPE_Addr *remote_addr=0, ACE_Time_Value *timeout=0, int restart=1, int reset_new_handle=0)
void dump (void) const
 Dump the state of an object.


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Private Attributes

ACE_Thread_Manager tm
 Manage threads.

ACE_Message_Block mb_
 To confirm connection establishment.


Detailed Description

Defines the format and interface for the listener side of the ACE_UPIPE_Stream.

Definition at line 38 of file UPIPE_Acceptor.h.


Constructor & Destructor Documentation

ACE_UPIPE_Acceptor::ACE_UPIPE_Acceptor void   ) 
 

Default constructor.

Definition at line 29 of file UPIPE_Acceptor.cpp.

References ACE_TRACE.

00030   : mb_ (sizeof (ACE_UPIPE_Stream *))
00031 {
00032   ACE_TRACE ("ACE_UPIPE_Acceptor::ACE_UPIPE_Acceptor");
00033 }

ACE_UPIPE_Acceptor::ACE_UPIPE_Acceptor const ACE_UPIPE_Addr local_sap,
int  reuse_addr = 0
 

Initialize passive endpoint.

Definition at line 59 of file UPIPE_Acceptor.cpp.

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

00061   : mb_ (sizeof (ACE_UPIPE_Stream *))
00062 {
00063   ACE_TRACE ("ACE_UPIPE_Acceptor::ACE_UPIPE_Acceptor");
00064 
00065   if (this->open (local_addr, reuse_addr) == -1)
00066     ACE_ERROR ((LM_ERROR,
00067                 ACE_LIB_TEXT ("%p\n"),
00068                 ACE_LIB_TEXT ("ACE_UPIPE_Acceptor")));
00069 }

ACE_UPIPE_Acceptor::~ACE_UPIPE_Acceptor void   ) 
 

Close down and release resources.

Definition at line 35 of file UPIPE_Acceptor.cpp.

References ACE_TRACE.

00036 {
00037   ACE_TRACE ("ACE_UPIPE_Acceptor::~ACE_UPIPE_Acceptor");
00038 }


Member Function Documentation

int ACE_UPIPE_Acceptor::accept ACE_UPIPE_Stream server_stream,
ACE_UPIPE_Addr remote_addr = 0,
ACE_Time_Value timeout = 0,
int  restart = 1,
int  reset_new_handle = 0
 

Accept a new data transfer connection. A timeout of 0 means block forever, a timeout of {0, 0} means poll. restart == 1 means "restart if interrupted."

Definition at line 72 of file UPIPE_Acceptor.cpp.

References ACE_SPIPE_Acceptor::accept(), ACE_ERROR, ACE_GUARD_RETURN, ACE_LIB_TEXT, ACE_TRACE, ACE_UPIPE_Stream::get_handle(), ACE_IPC_SAP::get_handle(), ACE_SPIPE::get_local_addr(), ACE_SPIPE_Stream::get_remote_addr(), ACE_Stream<>::link(), LM_ERROR, ACE_SPIPE::local_addr_, ACE_OS::read(), ACE_UPIPE_Stream::reference_count_, ACE_UPIPE_Stream::remote_addr_, ACE_UPIPE_Stream::send(), ACE_IPC_SAP::set_handle(), and ACE_UPIPE_Stream::stream_.

00077 {
00078   ACE_TRACE ("ACE_UPIPE_Acceptor::accept");
00079   ACE_UNUSED_ARG (reset_new_handle);
00080 
00081   ACE_SPIPE_Stream new_io;
00082 
00083   if (this->ACE_SPIPE_Acceptor::accept (new_io, remote_addr,
00084                                         timeout, restart) == -1)
00085     return -1;
00086   else
00087     {
00088       ACE_UPIPE_Stream *remote_stream = 0;
00089 
00090       ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, new_stream.lock_, -1));
00091 
00092       new_stream.set_handle (new_io.get_handle ());
00093       new_stream.reference_count_++;
00094 
00095       // Transfer address ownership.
00096       new_io.get_local_addr (new_stream.local_addr_);
00097       new_io.get_remote_addr (new_stream.remote_addr_);
00098 
00099       // Now that we got the handle, we'll read the address of the
00100       // connector-side ACE_UPIPE_Stream out of the pipe and link that
00101       // ACE_UPIPE_Stream to our ACE_UPIPE_Stream.
00102 
00103       if (ACE_OS::read (new_stream.get_handle (),
00104                         (char *) &remote_stream,
00105                         sizeof remote_stream) == -1)
00106         ACE_ERROR ((LM_ERROR,
00107                     ACE_LIB_TEXT ("ACE_UPIPE_Acceptor: %p\n"),
00108                     ACE_LIB_TEXT ("read stream address failed")));
00109       else if (new_stream.stream_.link (remote_stream->stream_) == -1)
00110         ACE_ERROR ((LM_ERROR,
00111                     ACE_LIB_TEXT ("ACE_UPIPE_Acceptor: %p\n"),
00112                     ACE_LIB_TEXT ("link streams failed")));
00113       // Send a message over the new streampipe to confirm acceptance.
00114       else if (new_stream.send (&mb_, 0) == -1)
00115         ACE_ERROR ((LM_ERROR,
00116                     ACE_LIB_TEXT ("ACE_UPIPE_Acceptor: %p\n"),
00117                     ACE_LIB_TEXT ("linked stream.put failed")));
00118 
00119       // Close down the new_stream at this point in order to conserve
00120       // handles.  Note that we don't need the SPIPE connection
00121       // anymore since we're now linked via the <Message_Queue>.
00122       new_stream.ACE_SPIPE::close ();
00123       return 0;
00124     }
00125 }

int ACE_UPIPE_Acceptor::close void   ) 
 

Close down and release resources.

Reimplemented from ACE_SPIPE_Acceptor.

Definition at line 51 of file UPIPE_Acceptor.cpp.

References ACE_TRACE, and ACE_SPIPE_Acceptor::close().

00052 {
00053   ACE_TRACE ("ACE_UPIPE_Acceptor::close");
00054   return this->ACE_SPIPE_Acceptor::close ();
00055 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL void ACE_UPIPE_Acceptor::dump void   )  const
 

Dump the state of an object.

Reimplemented from ACE_SPIPE_Acceptor.

Definition at line 20 of file UPIPE_Acceptor.cpp.

References ACE_TRACE.

00021 {
00022 #if defined (ACE_HAS_DUMP)
00023   ACE_TRACE ("ACE_UPIPE_Acceptor::dump");
00024 #endif /* ACE_HAS_DUMP */
00025 }

int ACE_UPIPE_Acceptor::open const ACE_UPIPE_Addr local_sap,
int  reuse_addr = 0
 

Initialize passive endpoint.

Definition at line 43 of file UPIPE_Acceptor.cpp.

References ACE_TRACE, and ACE_SPIPE_Acceptor::open().

Referenced by ACE_UPIPE_Acceptor().

00045 {
00046   ACE_TRACE ("ACE_UPIPE_Acceptor::open");
00047   return this->ACE_SPIPE_Acceptor::open (local_addr, reuse_addr);
00048 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_UPIPE_Acceptor::remove void   ) 
 

Close down and release resources and remove the underlying SPIPE rendezvous point.

Reimplemented from ACE_SPIPE_Acceptor.

Definition at line 8 of file UPIPE_Acceptor.inl.

References ACE_TRACE, and ACE_SPIPE_Acceptor::remove().

00009 {
00010   ACE_TRACE ("ACE_UPIPE_Acceptor::remove");
00011   return this->ACE_SPIPE_Acceptor::remove ();
00012 }


Member Data Documentation

ACE_UPIPE_Acceptor::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_SPIPE_Acceptor.

Definition at line 79 of file UPIPE_Acceptor.h.

ACE_Message_Block ACE_UPIPE_Acceptor::mb_ [private]
 

To confirm connection establishment.

Definition at line 86 of file UPIPE_Acceptor.h.

ACE_Thread_Manager ACE_UPIPE_Acceptor::tm [private]
 

Manage threads.

Definition at line 83 of file UPIPE_Acceptor.h.


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