conexus logo

Conexus::NSPR::UDP Class Reference
[Conexus I/O Endpoints with NSPR supportConexus I/O Endpoints]

This class encapsulates a socket used for UDP/IP communications. More...

#include <udp.h>

Inheritance diagram for Conexus::NSPR::UDP:

Inheritance graph
[legend]

List of all members.

Public Types

typedef ConexusPointer< UDPpointer

Public Member Functions

virtual ~UDP () throw ()
virtual void open () throw ( open_exception )
virtual void bind () throw ( bind_exception )
virtual void bind (Conexus::Address &a) throw ( bind_exception )
virtual void close () throw ( close_exception )
virtual void connect () throw ( connect_exception )
 Overloads the Socket ancestor send method to ensure that the socket is connected before trying to send.
virtual void connect (Address &a) throw ( connect_exception )
virtual void set_write_without_connect (bool value=true)
 There are some circumstances in which it may be desirable to set a default address and have the send method transparently call the sendto method without connecting rather than connecting and calling the send method.
virtual bool write_without_connect () const
virtual bool multicast_auto_join () const
virtual void set_multicast_auto_join (bool value=true)
virtual int multicast_hops ()
 Returns the multicast ttl of the currently associated interface.
virtual void set_multicast_hops (int hops)
 Sets the multicast ttl of the currently associated interface to hops.
virtual bool multicast_loop ()
 If true multicast packets are looped back to local sockets.
virtual void set_multicast_loop (bool loop)
 If parameter loop is true then multicast packets are looped back to local sockets.

Static Public Member Functions

static UDP::pointer create (uint16_t localport=0, uint16_t remoteport=0)
static UDP::pointer create (uint32_t host, uint16_t localport, uint16_t remoteport)
static UDP::pointer create (const std::string &host, uint16_t localport=0, uint16_t remoteport=0)

Protected Member Functions

 UDP (uint32_t host, uint16_t localport, uint16_t remoteport)
 UDP (const std::string &host, uint16_t localport, uint16_t remoteport)
virtual void join ()
 Joins the multicast group specified by addr.
virtual void leave ()
 Leaves the multicast group specified by addr.
virtual size_t write_data (const Data data, Timeout timeout) throw (write_exception)

Protected Attributes

bool m_write_without_connect
bool m_multicast_auto_join
bool m_multicast_joined


Detailed Description

This class encapsulates a socket used for UDP/IP communications.

Author:
Rick L Vinyard Jr <rvinyard@cs.nmsu.edu>

Member Typedef Documentation

typedef ConexusPointer<UDP> Conexus::NSPR::UDP::pointer

Reimplemented from Conexus::NSPR::Socket.


Constructor & Destructor Documentation

Conexus::NSPR::UDP::UDP ( uint32_t  host,
uint16_t  localport,
uint16_t  remoteport 
) [protected]

Conexus::NSPR::UDP::UDP ( const std::string &  host,
uint16_t  localport,
uint16_t  remoteport 
) [protected]

Conexus::NSPR::UDP::~UDP (  )  throw () [virtual]

References leave(), and m_multicast_joined.


Member Function Documentation

void Conexus::NSPR::UDP::bind ( Conexus::Address a  )  throw ( bind_exception ) [virtual]

void Conexus::NSPR::UDP::bind (  )  throw ( bind_exception ) [virtual]

void Conexus::NSPR::UDP::close (  )  throw ( close_exception ) [virtual]

References leave(), and m_multicast_joined.

void Conexus::NSPR::UDP::connect ( Address a  )  throw ( connect_exception ) [virtual]

void Conexus::NSPR::UDP::connect (  )  throw ( connect_exception ) [virtual]

Overloads the Socket ancestor send method to ensure that the socket is connected before trying to send.

Receives a single datagram from the UDP socket up to s bytes in size; allocates any memory necessary as a smart pointer contained in the returned Data object.

If s < 0 then receives the next pending datagram, however large it may be.

Reimplemented from Conexus::NSPR::Socket.

References Conexus::NSPR::Socket::m_remote_address.

UDP::pointer Conexus::NSPR::UDP::create ( const std::string &  host,
uint16_t  localport = 0,
uint16_t  remoteport = 0 
) [static]

References UDP().

UDP::pointer Conexus::NSPR::UDP::create ( uint32_t  host,
uint16_t  localport,
uint16_t  remoteport 
) [static]

References UDP().

UDP::pointer Conexus::NSPR::UDP::create ( uint16_t  localport = 0,
uint16_t  remoteport = 0 
) [static]

References UDP().

void Conexus::NSPR::UDP::join (  )  [protected, virtual]

Joins the multicast group specified by addr.

Referenced by bind().

void Conexus::NSPR::UDP::leave (  )  [protected, virtual]

Leaves the multicast group specified by addr.

Referenced by close(), and ~UDP().

bool Conexus::NSPR::UDP::multicast_auto_join (  )  const [virtual]

References m_multicast_auto_join.

int Conexus::NSPR::UDP::multicast_hops (  )  [virtual]

Returns the multicast ttl of the currently associated interface.

bool Conexus::NSPR::UDP::multicast_loop (  )  [virtual]

If true multicast packets are looped back to local sockets.

void Conexus::NSPR::UDP::open (  )  throw ( open_exception ) [virtual]

void Conexus::NSPR::UDP::set_multicast_auto_join ( bool  value = true  )  [virtual]

References m_multicast_auto_join.

void Conexus::NSPR::UDP::set_multicast_hops ( int  hops  )  [virtual]

Sets the multicast ttl of the currently associated interface to hops.

void Conexus::NSPR::UDP::set_multicast_loop ( bool  loop  )  [virtual]

If parameter loop is true then multicast packets are looped back to local sockets.

void Conexus::NSPR::UDP::set_write_without_connect ( bool  value = true  )  [virtual]

There are some circumstances in which it may be desirable to set a default address and have the send method transparently call the sendto method without connecting rather than connecting and calling the send method.

A specific example of this is when the remote address/port may occassionally be unavailable. In this case the destination may generate an ICMP UNREACHABLE message, and in accordance with RFC 1122 the local machine will fail any future sends on a connected port, throwing a write::connection_refused exception. If you want to ensure that the datagram is sent contrary to RFC 1122 you could set the default address, set send without connect and call send without throwing connection exceptions.

But, since this is contrary to RFC 1122 behavior you should really think about your design before setting this.

References m_write_without_connect.

size_t Conexus::NSPR::UDP::write_data ( const Data  data,
Timeout  timeout 
) throw (write_exception) [protected, virtual]

bool Conexus::NSPR::UDP::write_without_connect (  )  const [virtual]


Member Data Documentation

Referenced by close(), and ~UDP().


The documentation for this class was generated from the following files:

Generated on Wed Jul 8 15:51:29 2009 for conexus by doxygen 1.5.8