ACE_SOCK_Dgram_SC< STREAM > Class Template Reference

"Dgram_SC" is short for "Datagram Self-Contained." More...

#include <IOStream_T.h>

Collaboration diagram for ACE_SOCK_Dgram_SC< STREAM >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_SOCK_Dgram_SC (void)
 ACE_SOCK_Dgram_SC (STREAM &source, ACE_INET_Addr &dest)
ssize_t send_n (char *buf, ssize_t len)
ssize_t recv (char *buf, ssize_t len, ACE_Time_Value *tv=0)
ssize_t recv (char *buf, ssize_t len, int flags, ACE_Time_Value *tv=0)
ssize_t recv_n (char *buf, ssize_t len, int flags=0, ACE_Time_Value *tv=0)
int get_remote_addr (ACE_INET_Addr &addr) const

Protected Attributes

ACE_INET_Addr peer_

Detailed Description

template<class STREAM>
class ACE_SOCK_Dgram_SC< STREAM >

"Dgram_SC" is short for "Datagram Self-Contained."

Datagrams don't have the notion of a "peer". Each send and receive on a datagram can go to a different peer if you want. If you're using datagrams for stream activity, you probably want 'em all to go to (and come from) the same place. That's what this class is for. Here, we keep an address object so that we can remember who last sent us data. When we write back, we're then able to write back to that same address.

Definition at line 257 of file IOStream_T.h.


Constructor & Destructor Documentation

template<class STREAM>
ACE_INLINE ACE_SOCK_Dgram_SC< STREAM >::ACE_SOCK_Dgram_SC ( void   ) 

Definition at line 39 of file IOStream_T.inl.

00040 {
00041 }

template<class STREAM>
ACE_INLINE ACE_SOCK_Dgram_SC< STREAM >::ACE_SOCK_Dgram_SC ( STREAM &  source,
ACE_INET_Addr dest 
)

Definition at line 44 of file IOStream_T.inl.

00046   : STREAM (source),
00047     peer_ (dest)
00048 {
00049 }


Member Function Documentation

template<class STREAM>
ACE_INLINE int ACE_SOCK_Dgram_SC< STREAM >::get_remote_addr ( ACE_INET_Addr addr  )  const

Definition at line 117 of file IOStream_T.inl.

References ACE_SOCK_Dgram_SC< STREAM >::peer_.

00118 {
00119   addr = peer_;
00120   return 0;
00121 }

template<class STREAM>
ACE_INLINE ssize_t ACE_SOCK_Dgram_SC< STREAM >::recv ( char *  buf,
ssize_t  len,
int  flags,
ACE_Time_Value tv = 0 
)

Definition at line 69 of file IOStream_T.inl.

References ACE_BIT_ENABLED, ACE::get_handle(), MSG_PEEK, ACE_SOCK_Dgram_SC< STREAM >::peer_, ACE::recv(), ACE_OS::select(), and ACE_Handle_Set::set_bit().

00073 {
00074   if (tv != 0)
00075     {
00076       ACE_HANDLE handle = this->get_handle ();
00077       ACE_Handle_Set handle_set;
00078 
00079       handle_set.set_bit (handle);
00080 
00081       switch (ACE_OS::select (int (handle) + 1,
00082                               (fd_set *) handle_set, // read_fds.
00083                               (fd_set *) 0,          // write_fds.
00084                               (fd_set *) 0,          // exception_fds.
00085                               tv))
00086         {
00087         case 0:
00088           errno = ETIME;
00089         case -1:
00090           return -1;
00091         default:
00092           ;     // Do the 'recv' below
00093         }
00094     }
00095 
00096   int rval = STREAM::recv (buf, len, peer_, flags);
00097 #if defined (ACE_WIN32)
00098   if (rval == SOCKET_ERROR)
00099     if (::WSAGetLastError () == WSAEMSGSIZE)
00100       if (ACE_BIT_ENABLED (flags, MSG_PEEK))
00101         rval = len;
00102 #endif /* ACE_WIN32 */
00103   return rval < len ? rval : len;
00104 }

template<class STREAM>
ACE_INLINE ssize_t ACE_SOCK_Dgram_SC< STREAM >::recv ( char *  buf,
ssize_t  len,
ACE_Time_Value tv = 0 
)

Definition at line 59 of file IOStream_T.inl.

Referenced by ACE_SOCK_Dgram_SC< STREAM >::recv_n().

00062 {
00063   //FUZZ: disable check_for_lack_ACE_OS
00064   return recv (buf, len, 0, tv);
00065   //FUZZ: enable check_for_lack_ACE_OS
00066 }

template<class STREAM>
ACE_INLINE ssize_t ACE_SOCK_Dgram_SC< STREAM >::recv_n ( char *  buf,
ssize_t  len,
int  flags = 0,
ACE_Time_Value tv = 0 
)

Definition at line 107 of file IOStream_T.inl.

References ACE_SOCK_Dgram_SC< STREAM >::recv().

00111 {
00112   int rval = this->recv (buf, len, flags, tv);
00113   return rval;
00114 }

template<class STREAM>
ACE_INLINE ssize_t ACE_SOCK_Dgram_SC< STREAM >::send_n ( char *  buf,
ssize_t  len 
)

Definition at line 52 of file IOStream_T.inl.

References ACE_SOCK_Dgram_SC< STREAM >::peer_, and ACE::send().

00054 {
00055   return STREAM::send (buf, len, peer_);
00056 }


Member Data Documentation

template<class STREAM>
ACE_INET_Addr ACE_SOCK_Dgram_SC< STREAM >::peer_ [protected]

Definition at line 278 of file IOStream_T.h.

Referenced by ACE_SOCK_Dgram_SC< STREAM >::get_remote_addr(), ACE_SOCK_Dgram_SC< STREAM >::recv(), and ACE_SOCK_Dgram_SC< STREAM >::send_n().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:38 2010 for ACE by  doxygen 1.4.7