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

TLI_Stream.cpp

Go to the documentation of this file.
00001 #include "ace_pch.h"
00002 // $Id: TLI_Stream.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:22 chad Exp $
00003 
00004 /* Defines the member functions for the base class of the ACE_TLI_Stream
00005    abstraction. */
00006 
00007 #include "ace/TLI_Stream.h"
00008 #include "ace/ACE.h"
00009 
00010 ACE_RCSID(ace, TLI_Stream, "$Id: TLI_Stream.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:22 chad Exp $")
00011 
00012 #if defined (ACE_HAS_TLI)
00013 
00014 #if !defined (__ACE_INLINE__)
00015 #include "ace/TLI_Stream.i"
00016 #endif /* __ACE_INLINE__ */
00017 
00018 ACE_ALLOC_HOOK_DEFINE(ACE_TLI_Stream)
00019 
00020 void
00021 ACE_TLI_Stream::dump (void) const
00022 {
00023   ACE_TRACE ("ACE_TLI_Stream::dump");
00024 }
00025 
00026 ACE_TLI_Stream::ACE_TLI_Stream (void)
00027   : rwflag_ (0)
00028 {
00029   ACE_TRACE ("ACE_TLI_Stream::ACE_TLI_Stream");
00030 }
00031 
00032 int
00033 ACE_TLI_Stream::get_remote_addr (ACE_Addr &sa) const
00034 {
00035   ACE_TRACE ("ACE_TLI_Stream::get_remote_addr");
00036 
00037 #if defined (ACE_HAS_SVR4_TLI)
00038   struct netbuf name;
00039   name.maxlen = sa.get_size ();
00040   name.buf = (char *) sa.get_addr ();
00041 
00042   // if (ACE_OS::t_getname (this->get_handle (), &name, REMOTENAME) == -1)
00043   if (ACE_OS::ioctl (this->get_handle (),
00044                      TI_GETPEERNAME,
00045                      &name) == -1)
00046     return -1;
00047   else
00048     return 0;
00049 #else /* SunOS4 */
00050   ACE_UNUSED_ARG (sa);
00051   ACE_NOTSUP_RETURN (-1);
00052 #endif /* ACE_HAS_SVR4_TLI */
00053 }
00054 
00055 // Send a release and then await the release from the other side.
00056 
00057 int
00058 ACE_TLI_Stream::active_close (void)
00059 {
00060   ACE_TRACE ("ACE_TLI_Stream::active_close");
00061   char buf;
00062 
00063   if (this->sndrel () == -1)
00064     return -1;
00065   else if (this->recv (&buf, sizeof buf) == -1)
00066     {
00067       if (t_errno == TLOOK && this->look () == T_ORDREL)
00068         {
00069           if (this->rcvrel () == -1)
00070             return -1;
00071         }
00072       else
00073         return -1;
00074     }
00075 
00076   return this->close ();
00077 }
00078 
00079 // Acknowledge the release from the other side and then send the
00080 // release to the other side.
00081 
00082 int
00083 ACE_TLI_Stream::passive_close (void)
00084 {
00085   ACE_TRACE ("ACE_TLI_Stream::passive_close");
00086 
00087   if (this->rcvrel () == -1)
00088     return -1;
00089   else if (this->sndrel () == -1)
00090     return -1;
00091 
00092   return this->close ();
00093 }
00094 
00095 int
00096 ACE_TLI_Stream::close (void)
00097 {
00098   ACE_TRACE ("ACE_TLI_Stream::close");
00099 
00100   ACE_HANDLE fd = this->get_handle ();
00101 
00102   this->set_handle (ACE_INVALID_HANDLE);
00103 
00104 #if !defined (ACE_WIN32)
00105   if (this->rwflag_)
00106     return ACE_OS::close (fd);
00107   else
00108 #endif /* ACE_WIN32 */
00109     return ACE_OS::t_close (fd);
00110 }
00111 
00112 ssize_t
00113 ACE_TLI_Stream::send (const void *buf,
00114                       size_t n,
00115                       const ACE_Time_Value *timeout) const
00116 {
00117   ACE_TRACE ("ACE_TLI_Stream::send");
00118   return ACE::send (this->get_handle (),
00119                     buf,
00120                     n,
00121                     timeout);
00122 }
00123 
00124 ssize_t
00125 ACE_TLI_Stream::send (const void *buf,
00126                       size_t n,
00127                       int flags,
00128                       const ACE_Time_Value *timeout) const
00129 {
00130   ACE_TRACE ("ACE_TLI_Stream::send");
00131   return ACE::t_snd (this->get_handle (),
00132                      buf,
00133                      n,
00134                      flags,
00135                      timeout);
00136 }
00137 
00138 ssize_t
00139 ACE_TLI_Stream::recv (void *buf,
00140                       size_t n,
00141                       const ACE_Time_Value *timeout) const
00142 {
00143   ACE_TRACE ("ACE_TLI_Stream::recv");
00144   return ACE::recv (this->get_handle (),
00145                     buf,
00146                     n,
00147                     timeout);
00148 }
00149 
00150 ssize_t
00151 ACE_TLI_Stream::recv (void *buf,
00152                       size_t n,
00153                       int *flags,
00154                       const ACE_Time_Value *timeout) const
00155 {
00156   ACE_TRACE ("ACE_TLI_Stream::recv");
00157   int f = 0;
00158 
00159   if (flags == 0)
00160     flags = &f;
00161 
00162   return ACE::t_rcv (this->get_handle (),
00163                      buf,
00164                      n,
00165                      flags,
00166                      timeout);
00167 }
00168 
00169 ssize_t
00170 ACE_TLI_Stream::send_n (const void *buf,
00171                         size_t n,
00172                         const ACE_Time_Value *timeout,
00173                         size_t *bytes_transferred) const
00174 {
00175   ACE_TRACE ("ACE_TLI_Stream::send_n");
00176   return ACE::send_n (this->get_handle (),
00177                       buf,
00178                       n,
00179                       timeout,
00180                       bytes_transferred);
00181 }
00182 
00183 ssize_t
00184 ACE_TLI_Stream::send_n (const void *buf,
00185                         size_t n,
00186                         int flags,
00187                         const ACE_Time_Value *timeout,
00188                         size_t *bytes_transferred) const
00189 {
00190   ACE_TRACE ("ACE_TLI_Stream::send_n");
00191 
00192   return ACE::t_snd_n (this->get_handle (),
00193                        buf,
00194                        n,
00195                        flags,
00196                        timeout,
00197                        bytes_transferred);
00198 }
00199 
00200 ssize_t
00201 ACE_TLI_Stream::recv_n (void *buf,
00202                         size_t n,
00203                         const ACE_Time_Value *timeout,
00204                         size_t *bytes_transferred) const
00205 {
00206   ACE_TRACE ("ACE_TLI_Stream::recv_n");
00207   return ACE::recv_n (this->get_handle (),
00208                       buf,
00209                       n,
00210                       timeout,
00211                       bytes_transferred);
00212 }
00213 
00214 ssize_t
00215 ACE_TLI_Stream::recv_n (void *buf,
00216                         size_t n,
00217                         int *flags,
00218                         const ACE_Time_Value *timeout,
00219                         size_t *bytes_transferred) const
00220 {
00221   ACE_TRACE ("ACE_TLI_Stream::recv_n");
00222 
00223   return ACE::t_rcv_n (this->get_handle (),
00224                        buf,
00225                        n,
00226                        flags,
00227                        timeout,
00228                        bytes_transferred);
00229 }
00230 
00231 #endif /* ACE_HAS_TLI */

Generated on Mon Jun 16 11:21:55 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002