Public Member Functions | Protected Attributes

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_SOCK_Dgram_SC< STREAM >::ACE_SOCK_Dgram_SC ( void   )  [inline]

Definition at line 39 of file IOStream_T.inl.

{
}

template<class STREAM >
ACE_SOCK_Dgram_SC< STREAM >::ACE_SOCK_Dgram_SC ( STREAM &  source,
ACE_INET_Addr dest 
) [inline]

Definition at line 44 of file IOStream_T.inl.

  : STREAM (source),
    peer_ (dest)
{
}


Member Function Documentation

template<class STREAM >
int ACE_SOCK_Dgram_SC< STREAM >::get_remote_addr ( ACE_INET_Addr addr  )  const [inline]

Definition at line 117 of file IOStream_T.inl.

{
  addr = peer_;
  return 0;
}

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

Definition at line 59 of file IOStream_T.inl.

{
  //FUZZ: disable check_for_lack_ACE_OS
  return recv (buf, len, 0, tv);
  //FUZZ: enable check_for_lack_ACE_OS
}

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

Definition at line 69 of file IOStream_T.inl.

{
  if (tv != 0)
    {
      ACE_HANDLE handle = this->get_handle ();
      ACE_Handle_Set handle_set;

      handle_set.set_bit (handle);

      switch (ACE_OS::select (int (handle) + 1,
                              (fd_set *) handle_set, // read_fds.
                              (fd_set *) 0,          // write_fds.
                              (fd_set *) 0,          // exception_fds.
                              tv))
        {
        case 0:
          errno = ETIME;
        case -1:
          return -1;
        default:
          ;     // Do the 'recv' below
        }
    }

  int rval = STREAM::recv (buf, len, peer_, flags);
#if defined (ACE_WIN32)
  if (rval == SOCKET_ERROR)
    if (::WSAGetLastError () == WSAEMSGSIZE)
      if (ACE_BIT_ENABLED (flags, MSG_PEEK))
        rval = len;
#endif /* ACE_WIN32 */
  return rval < len ? rval : len;
}

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

Definition at line 107 of file IOStream_T.inl.

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

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

Definition at line 52 of file IOStream_T.inl.

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


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.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines