ACE_TLI_Stream Class Reference

Defines the member functions for ACE_TLI_Stream abstraction. More...

#include <TLI_Stream.h>

Inheritance diagram for ACE_TLI_Stream:

Inheritance graph
[legend]
Collaboration diagram for ACE_TLI_Stream:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_INET_Addr PEER_ADDR

Public Member Functions

 ACE_TLI_Stream (void)
 Default constructor.

int close (void)
 Close down and release resources.

int active_close (void)
 Send a release and then await the release from the other side.

int passive_close (void)
int get_remote_addr (ACE_Addr &) const
 Return address of remotely connected peer.

ssize_t send (const void *buf, size_t n, int flags, const ACE_Time_Value *timeout=0) const
 Send an n byte buffer to the connected socket (uses t_snd(3)).

ssize_t recv (void *buf, size_t n, int *flags, const ACE_Time_Value *timeout=0) const
 Recv an n byte buffer from the connected socket (uses t_rcv(3)).

ssize_t send_n (const void *buf, size_t n, int flags, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) const
 Send exactly n bytes to the connected socket (uses t_snd(3)).

ssize_t recv_n (void *buf, size_t n, int *flags, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) const
 Recv exactly n bytes from the connected socket (uses t_rcv(3)).

ssize_t send (const void *buf, size_t n, const ACE_Time_Value *timeout=0) const
 Send an n byte buffer to the connected socket (uses write(2)).

ssize_t recv (void *buf, size_t n, const ACE_Time_Value *timeout=0) const
 Recv an n byte buffer from the connected socket (uses read(2)).

ssize_t send_n (const void *buf, size_t n, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) const
 Send n bytes, keep trying until n are sent (uses write(2)).

ssize_t recv_n (void *buf, size_t n, const ACE_Time_Value *timeout=0, size_t *bytes_transferred=0) const
 Recv n bytes, keep trying until n are received (uses read (2)).

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


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Private Member Functions

int get_rwflag (void) const
 Get rwflag.

void set_rwflag (int value)
 Set rwflag.


Private Attributes

int rwflag_
 Indicates whether the tirdwr module should be pushed.


Friends

class ACE_TLI_Acceptor
class ACE_TLI_Connector

Detailed Description

Defines the member functions for ACE_TLI_Stream abstraction.

Definition at line 39 of file TLI_Stream.h.


Member Typedef Documentation

typedef ACE_INET_Addr ACE_TLI_Stream::PEER_ADDR
 

Definition at line 114 of file TLI_Stream.h.


Constructor & Destructor Documentation

ACE_TLI_Stream::ACE_TLI_Stream void   ) 
 

Default constructor.

Definition at line 30 of file TLI_Stream.cpp.

References ACE_TRACE.

00031   : rwflag_ (0)
00032 {
00033   ACE_TRACE ("ACE_TLI_Stream::ACE_TLI_Stream");
00034 }


Member Function Documentation

int ACE_TLI_Stream::active_close void   ) 
 

Send a release and then await the release from the other side.

Definition at line 54 of file TLI_Stream.cpp.

References ACE_TRACE, close(), ACE_TLI::look(), ACE_TLI::rcvrel(), recv(), and ACE_TLI::sndrel().

00055 {
00056   ACE_TRACE ("ACE_TLI_Stream::active_close");
00057   char buf;
00058 
00059   if (this->sndrel () == -1)
00060     return -1;
00061   else if (this->recv (&buf, sizeof buf) == -1)
00062     {
00063       if (t_errno == TLOOK && this->look () == T_ORDREL)
00064         {
00065           if (this->rcvrel () == -1)
00066             return -1;
00067         }
00068       else
00069         return -1;
00070     }
00071 
00072   return this->close ();
00073 }

int ACE_TLI_Stream::close void   ) 
 

Close down and release resources.

Reimplemented from ACE_TLI.

Definition at line 92 of file TLI_Stream.cpp.

References ACE_TRACE, ACE_OS::close(), ACE_IPC_SAP::get_handle(), ACE_IPC_SAP::set_handle(), and ACE_OS::t_close().

Referenced by active_close(), ACE_TLI_Connector::complete(), ACE_TLI_Connector::connect(), and passive_close().

00093 {
00094   ACE_TRACE ("ACE_TLI_Stream::close");
00095 
00096   ACE_HANDLE fd = this->get_handle ();
00097 
00098   this->set_handle (ACE_INVALID_HANDLE);
00099 
00100 #if !defined (ACE_WIN32)
00101   if (this->rwflag_)
00102     return ACE_OS::close (fd);
00103   else
00104 #endif /* ACE_WIN32 */
00105     return ACE_OS::t_close (fd);
00106 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL void ACE_TLI_Stream::dump void   )  const
 

Dump the state of an object.

Reimplemented from ACE_TLI.

Definition at line 23 of file TLI_Stream.cpp.

References ACE_TRACE.

00024 {
00025 #if defined (ACE_HAS_DUMP)
00026   ACE_TRACE ("ACE_TLI_Stream::dump");
00027 #endif /* ACE_HAS_DUMP */
00028 }

int ACE_TLI_Stream::get_remote_addr ACE_Addr  )  const
 

Return address of remotely connected peer.

Definition at line 37 of file TLI_Stream.cpp.

References ACE_TRACE, ACE_Addr::get_addr(), ACE_Addr::get_size(), and ACE_OS::t_getname().

00038 {
00039   ACE_TRACE ("ACE_TLI_Stream::get_remote_addr");
00040 
00041   struct netbuf name;
00042   name.maxlen = sa.get_size ();
00043   name.buf = (char *) sa.get_addr ();
00044 
00045   if (ACE_OS::t_getname (this->get_handle (), &name, REMOTENAME) == -1)
00046     return -1;
00047   else
00048     return 0;
00049 }

ACE_INLINE int ACE_TLI_Stream::get_rwflag void   )  const [private]
 

Get rwflag.

Definition at line 19 of file TLI_Stream.inl.

References ACE_TRACE.

Referenced by ACE_TLI_Connector::connect().

00020 {
00021   ACE_TRACE ("ACE_TLI_Stream::get_rwflag");
00022   return this->rwflag_;
00023 }

int ACE_TLI_Stream::passive_close void   ) 
 

Acknowledge the release from the other side and then send the release to the other side.

Definition at line 79 of file TLI_Stream.cpp.

References ACE_TRACE, close(), ACE_TLI::rcvrel(), and ACE_TLI::sndrel().

00080 {
00081   ACE_TRACE ("ACE_TLI_Stream::passive_close");
00082 
00083   if (this->rcvrel () == -1)
00084     return -1;
00085   else if (this->sndrel () == -1)
00086     return -1;
00087 
00088   return this->close ();
00089 }

ssize_t ACE_TLI_Stream::recv void *  buf,
size_t  n,
const ACE_Time_Value timeout = 0
const
 

Recv an n byte buffer from the connected socket (uses read(2)).

Definition at line 135 of file TLI_Stream.cpp.

References ACE_TRACE, and ACE::recv().

00138 {
00139   ACE_TRACE ("ACE_TLI_Stream::recv");
00140   return ACE::recv (this->get_handle (),
00141                     buf,
00142                     n,
00143                     timeout);
00144 }

ssize_t ACE_TLI_Stream::recv void *  buf,
size_t  n,
int *  flags,
const ACE_Time_Value timeout = 0
const
 

Recv an n byte buffer from the connected socket (uses t_rcv(3)).

Definition at line 147 of file TLI_Stream.cpp.

References ACE_TRACE, and ACE::t_rcv().

Referenced by active_close().

00151 {
00152   ACE_TRACE ("ACE_TLI_Stream::recv");
00153   int f = 0;
00154 
00155   if (flags == 0)
00156     flags = &f;
00157 
00158   return ACE::t_rcv (this->get_handle (),
00159                      buf,
00160                      n,
00161                      flags,
00162                      timeout);
00163 }

ssize_t ACE_TLI_Stream::recv_n void *  buf,
size_t  n,
const ACE_Time_Value timeout = 0,
size_t *  bytes_transferred = 0
const
 

Recv n bytes, keep trying until n are received (uses read (2)).

Definition at line 197 of file TLI_Stream.cpp.

References ACE_TRACE, and ACE::recv_n().

00201 {
00202   ACE_TRACE ("ACE_TLI_Stream::recv_n");
00203   return ACE::recv_n (this->get_handle (),
00204                       buf,
00205                       n,
00206                       timeout,
00207                       bytes_transferred);
00208 }

ssize_t ACE_TLI_Stream::recv_n void *  buf,
size_t  n,
int *  flags,
const ACE_Time_Value timeout = 0,
size_t *  bytes_transferred = 0
const
 

Recv exactly n bytes from the connected socket (uses t_rcv(3)).

Definition at line 211 of file TLI_Stream.cpp.

References ACE_TRACE, and ACE::t_rcv_n().

00216 {
00217   ACE_TRACE ("ACE_TLI_Stream::recv_n");
00218 
00219   return ACE::t_rcv_n (this->get_handle (),
00220                        buf,
00221                        n,
00222                        flags,
00223                        timeout,
00224                        bytes_transferred);
00225 }

ssize_t ACE_TLI_Stream::send const void *  buf,
size_t  n,
const ACE_Time_Value timeout = 0
const
 

Send an n byte buffer to the connected socket (uses write(2)).

Definition at line 109 of file TLI_Stream.cpp.

References ACE_TRACE, and ACE::send().

00112 {
00113   ACE_TRACE ("ACE_TLI_Stream::send");
00114   return ACE::send (this->get_handle (),
00115                     buf,
00116                     n,
00117                     timeout);
00118 }

ssize_t ACE_TLI_Stream::send const void *  buf,
size_t  n,
int  flags,
const ACE_Time_Value timeout = 0
const
 

Send an n byte buffer to the connected socket (uses t_snd(3)).

Definition at line 121 of file TLI_Stream.cpp.

References ACE_TRACE, and ACE::t_snd().

00125 {
00126   ACE_TRACE ("ACE_TLI_Stream::send");
00127   return ACE::t_snd (this->get_handle (),
00128                      buf,
00129                      n,
00130                      flags,
00131                      timeout);
00132 }

ssize_t ACE_TLI_Stream::send_n const void *  buf,
size_t  n,
const ACE_Time_Value timeout = 0,
size_t *  bytes_transferred = 0
const
 

Send n bytes, keep trying until n are sent (uses write(2)).

Definition at line 166 of file TLI_Stream.cpp.

References ACE_TRACE, and ACE::send_n().

00170 {
00171   ACE_TRACE ("ACE_TLI_Stream::send_n");
00172   return ACE::send_n (this->get_handle (),
00173                       buf,
00174                       n,
00175                       timeout,
00176                       bytes_transferred);
00177 }

ssize_t ACE_TLI_Stream::send_n const void *  buf,
size_t  n,
int  flags,
const ACE_Time_Value timeout = 0,
size_t *  bytes_transferred = 0
const
 

Send exactly n bytes to the connected socket (uses t_snd(3)).

Definition at line 180 of file TLI_Stream.cpp.

References ACE_TRACE, and ACE::t_snd_n().

00185 {
00186   ACE_TRACE ("ACE_TLI_Stream::send_n");
00187 
00188   return ACE::t_snd_n (this->get_handle (),
00189                        buf,
00190                        n,
00191                        flags,
00192                        timeout,
00193                        bytes_transferred);
00194 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void ACE_TLI_Stream::set_rwflag int  value  )  [private]
 

Set rwflag.

Definition at line 11 of file TLI_Stream.inl.

References ACE_TRACE.

Referenced by ACE_TLI_Acceptor::accept(), and ACE_TLI_Connector::connect().

00012 {
00013   ACE_TRACE ("ACE_TLI_Stream::set_rwflag");
00014   this->rwflag_ = value;
00015 }


Friends And Related Function Documentation

friend class ACE_TLI_Acceptor [friend]
 

Definition at line 42 of file TLI_Stream.h.

friend class ACE_TLI_Connector [friend]
 

Definition at line 43 of file TLI_Stream.h.


Member Data Documentation

ACE_TLI_Stream::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_TLI.

Definition at line 120 of file TLI_Stream.h.

int ACE_TLI_Stream::rwflag_ [private]
 

Indicates whether the tirdwr module should be pushed.

Definition at line 124 of file TLI_Stream.h.


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