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

vpr::SocketDatagram_t Class Template Reference

Datagram socket interface. More...

#include <SocketDatagram_t.h>

Inheritance diagram for vpr::SocketDatagram_t:

Inheritance graph
[legend]
Collaboration diagram for vpr::SocketDatagram_t:

Collaboration graph
[legend]
List of all members.

Public Types

typedef SocketConfig_ Config
typedef Config::SocketDatagramImpl SocketDatagramImpl

Public Methods

 SocketDatagram_t ()
 Default constructor. More...

 SocketDatagram_t (const vpr::InetAddr &local_addr, const vpr::InetAddr &remote_addr)
 Constructor. More...

 SocketDatagram_t (const SocketDatagram_t &sock)
 Copy constructor. More...

virtual ~SocketDatagram_t ()
 Destructor. More...

vpr::ReturnStatus recvfrom (void *msg, const vpr::Uint32 len, const int flags, vpr::InetAddr &from, vpr::Uint32 &bytes_read, const vpr::Interval timeout=vpr::Interval::NoTimeout)
 Receives a message from some source. More...

vpr::ReturnStatus recvfrom (std::string &msg, const vpr::Uint32 len, const int flags, vpr::InetAddr &from, vpr::Uint32 &bytes_read, const vpr::Interval timeout=vpr::Interval::NoTimeout)
 Receives a message from some source. More...

vpr::ReturnStatus recvfrom (std::vector< vpr::Uint8 > &msg, const vpr::Uint32 len, const int flags, vpr::InetAddr &from, vpr::Uint32 &bytes_read, const vpr::Interval timeout=vpr::Interval::NoTimeout)
 Receives a message from some source. More...

vpr::ReturnStatus sendto (const void *msg, const vpr::Uint32 len, const int flags, const vpr::InetAddr &to, vpr::Uint32 &bytes_sent, const vpr::Interval timeout=vpr::Interval::NoTimeout)
 Sends a message to the designated recipient. More...

vpr::ReturnStatus sendto (const std::string &msg, const vpr::Uint32 len, const int flags, const vpr::InetAddr &to, vpr::Uint32 &bytes_sent, const vpr::Interval timeout=vpr::Interval::NoTimeout)
 Sends a message to the designated recipient. More...

vpr::ReturnStatus sendto (const std::vector< vpr::Uint8 > &msg, const vpr::Uint32 len, const int flags, const vpr::InetAddr &to, vpr::Uint32 &bytes_sent, const vpr::Interval timeout=vpr::Interval::NoTimeout)
 Sends a message to the designated recipient. More...


Public Attributes

boost::shared_ptr< SocketDatagramImplmSocketDgramImpl
 Platform-specific datagram socket implementation object. More...


Protected Methods

virtual vpr::ReturnStatus getOption (const vpr::SocketOptions::Types option, struct vpr::SocketOptions::Data &data) const
 Retrieves the value for the given option as set on the socket. More...

virtual vpr::ReturnStatus setOption (const vpr::SocketOptions::Types option, const struct vpr::SocketOptions::Data &data)
 Sets a value for the given option on the socket using the given data block. More...


Detailed Description

template<class SocketConfig_>
class vpr::SocketDatagram_t< SocketConfig_ >

Datagram socket interface.

Definition at line 61 of file SocketDatagram_t.h.


Member Typedef Documentation

template<class SocketConfig_>
typedef SocketConfig_ vpr::SocketDatagram_t::Config
 

Reimplemented from vpr::Socket_t< SocketConfig_ >.

Definition at line 65 of file SocketDatagram_t.h.

Referenced by SocketDatagram_t.

template<class SocketConfig_>
typedef Config::SocketDatagramImpl vpr::SocketDatagram_t::SocketDatagramImpl
 

Definition at line 66 of file SocketDatagram_t.h.

Referenced by SocketDatagram_t.


Constructor & Destructor Documentation

template<class SocketConfig_>
vpr::SocketDatagram_t< SocketConfig_ >::SocketDatagram_t   [inline]
 

Default constructor.

Definition at line 71 of file SocketDatagram_t.h.

References mSocketDgramImpl, and SocketDatagramImpl.

Referenced by SocketDatagram_t.

00071                       : mSocketDgramImpl()
00072    {
00073       mSocketDgramImpl = boost::shared_ptr<SocketDatagramImpl>(new SocketDatagramImpl);
00074       Socket_t<SocketConfig_>::mSocketImpl = mSocketDgramImpl;
00075    }

template<class SocketConfig_>
vpr::SocketDatagram_t< SocketConfig_ >::SocketDatagram_t const vpr::InetAddr   local_addr,
const vpr::InetAddr   remote_addr
[inline]
 

Constructor.

This takes a reference to a vpr::InetAddr object giving the local socket address and a reference to a vpr::InetAddr object giving the remote address.

Precondition:
addr is a reference to a valid vpr::InetAddr object.
Postcondition:
A socket is created using the contents of addr.
Parameters:
addr  A reference to a vpr::InetAddr object.

Definition at line 87 of file SocketDatagram_t.h.

References Config, mSocketDgramImpl, vpr::Socket_t< SocketConfig_ >::Socket_t, and SocketDatagramImpl.

00089       : Socket_t<Config>()
00090    {
00091       mSocketDgramImpl = boost::shared_ptr<SocketDatagramImpl>(new SocketDatagramImpl(local_addr, remote_addr));
00092       Socket_t<SocketConfig_>::mSocketImpl = mSocketDgramImpl;
00093    }

template<class SocketConfig_>
vpr::SocketDatagram_t< SocketConfig_ >::SocketDatagram_t const SocketDatagram_t< SocketConfig_ > &    sock [inline]
 

Copy constructor.

Parameters:
sock  The source socket object to be copied.

Definition at line 100 of file SocketDatagram_t.h.

References mSocketDgramImpl, and SocketDatagram_t.

00101       : mSocketDgramImpl(sock.mSocketDgramImpl)
00102    {
00103       Socket_t<SocketConfig_>::mSocketImpl = mSocketDgramImpl;
00104    }

template<class SocketConfig_>
virtual vpr::SocketDatagram_t< SocketConfig_ >::~SocketDatagram_t   [inline, virtual]
 

Destructor.

This currently does nothing.

Precondition:
None.
Postcondition:
None.

Definition at line 112 of file SocketDatagram_t.h.

00113    {
00114       /* nothing */ ;
00115    }


Member Function Documentation

template<class SocketConfig_>
vpr::ReturnStatus vpr::SocketDatagram_t< SocketConfig_ >::recvfrom void *    msg,
const vpr::Uint32    len,
const int    flags,
vpr::InetAddr   from,
vpr::Uint32   bytes_read,
const vpr::Interval    timeout = vpr::Interval::NoTimeout
[inline]
 

Receives a message from some source.

The source's address is writen into the by-reference parameter from.

Definition at line 121 of file SocketDatagram_t.h.

References mSocketDgramImpl, and vpr::Interval::NoTimeout.

Referenced by recvfrom.

00125    {
00126       return mSocketDgramImpl->recvfrom(msg, len, flags, from, bytes_read,
00127                                         timeout);
00128    }

template<class SocketConfig_>
vpr::ReturnStatus vpr::SocketDatagram_t< SocketConfig_ >::recvfrom std::string &    msg,
const vpr::Uint32    len,
const int    flags,
vpr::InetAddr   from,
vpr::Uint32   bytes_read,
const vpr::Interval    timeout = vpr::Interval::NoTimeout
[inline]
 

Receives a message from some source.

The source's address is writen into the by-reference parameter from.

Definition at line 134 of file SocketDatagram_t.h.

References vpr::Interval::NoTimeout, and recvfrom.

00138    {
00139       msg.resize(len);
00140       memset(&msg[0], '\0', msg.size());
00141 
00142       return recvfrom((void*) &msg[0], msg.size(), flags, from, bytes_read,
00143                       timeout);
00144    }

template<class SocketConfig_>
vpr::ReturnStatus vpr::SocketDatagram_t< SocketConfig_ >::recvfrom std::vector< vpr::Uint8 > &    msg,
const vpr::Uint32    len,
const int    flags,
vpr::InetAddr   from,
vpr::Uint32   bytes_read,
const vpr::Interval    timeout = vpr::Interval::NoTimeout
[inline]
 

Receives a message from some source.

The source's address is writen into the by-reference parameter from.

Definition at line 150 of file SocketDatagram_t.h.

References vpr::Interval::NoTimeout, recvfrom, and vpr::ReturnStatus::success.

00154    {
00155       vpr::ReturnStatus retval;
00156 
00157       msg.resize(len);
00158 
00159       memset(&msg[0], '\0', msg.size());
00160       retval = recvfrom((void*) &msg[0], msg.size(), flags, from, bytes_read,
00161                         timeout);
00162 
00163       // Size it down if needed, if (bytes_read==len), then resize does
00164       // nothing.
00165       if ( retval.success() )
00166       {
00167          msg.resize(bytes_read);
00168       }
00169 
00170       return retval;
00171    }

template<class SocketConfig_>
vpr::ReturnStatus vpr::SocketDatagram_t< SocketConfig_ >::sendto const void *    msg,
const vpr::Uint32    len,
const int    flags,
const vpr::InetAddr   to,
vpr::Uint32   bytes_sent,
const vpr::Interval    timeout = vpr::Interval::NoTimeout
[inline]
 

Sends a message to the designated recipient.

Definition at line 176 of file SocketDatagram_t.h.

References mSocketDgramImpl, and vpr::Interval::NoTimeout.

Referenced by sendto.

00180    {
00181       return mSocketDgramImpl->sendto(msg, len, flags, to, bytes_sent,
00182                                       timeout);
00183    }

template<class SocketConfig_>
vpr::ReturnStatus vpr::SocketDatagram_t< SocketConfig_ >::sendto const std::string &    msg,
const vpr::Uint32    len,
const int    flags,
const vpr::InetAddr   to,
vpr::Uint32   bytes_sent,
const vpr::Interval    timeout = vpr::Interval::NoTimeout
[inline]
 

Sends a message to the designated recipient.

Definition at line 188 of file SocketDatagram_t.h.

References vpr::Interval::NoTimeout, sendto, and vprASSERT.

00192    {
00193       vprASSERT(len <= msg.size() && "Length is bigger than data given");
00194       return sendto(msg.c_str(), len, flags, to, bytes_sent, timeout);
00195    }

template<class SocketConfig_>
vpr::ReturnStatus vpr::SocketDatagram_t< SocketConfig_ >::sendto const std::vector< vpr::Uint8 > &    msg,
const vpr::Uint32    len,
const int    flags,
const vpr::InetAddr   to,
vpr::Uint32   bytes_sent,
const vpr::Interval    timeout = vpr::Interval::NoTimeout
[inline]
 

Sends a message to the designated recipient.

Definition at line 200 of file SocketDatagram_t.h.

References vpr::Interval::NoTimeout, sendto, and vprASSERT.

00204    {
00205       vprASSERT(len <= msg.size() && "Length is bigger than data given");
00206       return sendto((const void*) &msg[0], len, flags, to, bytes_sent,
00207                     timeout);
00208    }

template<class SocketConfig_>
virtual vpr::ReturnStatus vpr::SocketDatagram_t< SocketConfig_ >::getOption const vpr::SocketOptions::Types    option,
struct vpr::SocketOptions::Data   data
const [inline, protected, virtual]
 

Retrieves the value for the given option as set on the socket.

Parameters:
option  The option to be queried.
data  A data buffer that will be used to store the value of the given option.
Returns:
vpr::ReturnStatus::Succeed is returned if the value for the given option was retrieved successfully.
vpr::ReturnStatus;:Fail is returned otherwise.

Reimplemented from vpr::Socket_t< SocketConfig_ >.

Definition at line 211 of file SocketDatagram_t.h.

References mSocketDgramImpl.

00213    {
00214       return mSocketDgramImpl->getOption(option, data);
00215    }

template<class SocketConfig_>
virtual vpr::ReturnStatus vpr::SocketDatagram_t< SocketConfig_ >::setOption const vpr::SocketOptions::Types    option,
const struct vpr::SocketOptions::Data   data
[inline, protected, virtual]
 

Sets a value for the given option on the socket using the given data block.

Parameters:
option  The option whose value will be set.
data  A data buffer containing the value to be used in setting the socket option.

Reimplemented from vpr::Socket_t< SocketConfig_ >.

Definition at line 217 of file SocketDatagram_t.h.

References mSocketDgramImpl.

00219    {
00220       return mSocketDgramImpl->setOption(option, data);
00221    }


Member Data Documentation

template<class SocketConfig_>
boost::shared_ptr<SocketDatagramImpl> vpr::SocketDatagram_t::mSocketDgramImpl
 

Platform-specific datagram socket implementation object.

Definition at line 229 of file SocketDatagram_t.h.

Referenced by getOption, recvfrom, sendto, setOption, and SocketDatagram_t.


The documentation for this class was generated from the following file:
Generated on Sun May 2 14:46:55 2004 for VR Juggler Portable Runtime by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002