conexus logo

Conexus::IPv4::UDP Class Reference
[IPv4 EndpointsConexus I/O Endpoints]

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

#include <conexus/ipv4_udp.h>

Inheritance diagram for Conexus::IPv4::UDP:

Inheritance graph
[legend]

List of all members.

Public Types

typedef ConexusPointer< UDPpointer

Public Member Functions

 CONEXUS_ENDPOINT_GENERIC_CREATE ()
virtual ~UDP () throw ()
virtual size_t input_available () throw ()
virtual void bind () throw ( bind_exception )
virtual void bind (const Conexus::Address &a) throw ( bind_exception )
virtual void close () throw ( close_exception )
virtual int output_pending ()
 Returns the size in bytes of the local send queue.
virtual void connect () throw ( connect_exception )
virtual void connect (const 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
void add_multicast_interface (unsigned iface_index)
void add_multicast_interface (const std::string &iface_name)
void remove_multicast_interface (unsigned iface_index)
void remove_multicast_interface (const std::string &iface_name)
bool is_multicast_interface (unsigned iface_index)
bool is_multicast_interface (const std::string &iface_name)
virtual bool suppress_multicast_join () const
virtual void set_suppress_multicast_join (bool value=true)
virtual unsigned multicast_hops ()
 Returns the multicast ttl of the currently associated address.
virtual void set_multicast_hops (unsigned hops)
 Sets the multicast ttl of the currently associated address to hops.
virtual bool multicast_loopback ()
 If true multicast packets are looped back to local sockets.
virtual void set_multicast_loopback (bool loopback)
 If parameter loop is true then multicast packets are looped back to local sockets.

Static Public Member Functions

static pointer create (uint16_t localport=0, uint16_t remoteport=0)
static pointer create (uint32_t local_if, uint16_t localport, uint16_t remoteport)
static pointer create (const std::string &local_if, uint16_t localport=0, uint16_t remoteport=0)
static unsigned int default_multicast_hops ()
static void set_default_multicast_hops (unsigned int hops)
static bool default_multicast_loopback ()
static void set_default_multicast_loopback (bool loopback)

Protected Member Functions

 UDP (uint32_t local_if, uint16_t localport, uint16_t remoteport)
 UDP (const std::string &local_if, uint16_t localport, uint16_t remoteport)
virtual void on_local_address_changed ()
virtual void on_remote_address_changed ()
virtual void join ()
 Issues a join on all multicast interfaces.
virtual void join (unsigned interface)
 Issues a join on the local address for the specified interface.
virtual void leave ()
 Issues a leave on all multicast interfaces.
virtual void leave (unsigned interface)
 Issues a leave on the local address for the specified interface.
virtual size_t write_data (const Data data, Timeout timeout) throw ( write_exception )
 Overloads the Socket ancestor send method to ensure that the socket is connected before trying to send.

Protected Attributes

bool m_write_without_connect
bool m_suppress_multicast_join
std::set< unsigned > m_multicast_interfaces
unsigned m_multicast_hops
bool m_multicast_loopback

Static Protected Attributes

static unsigned int m_default_hops = DEFAULT_IPV4_MULTICAST_HOPS
 All data output on this socket is accumulated into a single datagram that is transmitted when the socket is uncorked.
static bool m_default_loopback = DEFAULT_IPV4_MULTICAST_LOOP_BACK


Detailed Description

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

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

factory_client.cpp, factory_server.cpp, registry_client.cpp, and registry_server.cpp.


Member Typedef Documentation

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


Constructor & Destructor Documentation

Conexus::IPv4::UDP::UDP ( uint32_t  local_if,
uint16_t  localport,
uint16_t  remoteport 
) [protected]

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

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

References leave().


Member Function Documentation

void Conexus::IPv4::UDP::add_multicast_interface ( const std::string &  iface_name  ) 

void Conexus::IPv4::UDP::add_multicast_interface ( unsigned  iface_index  ) 

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

Reimplemented from Conexus::IPv4::IP.

Reimplemented in Conexus::IPv4::UDPPoset.

References Conexus::IPv4::IP::bind().

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

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

Reimplemented in Conexus::IPv4::UDPPoset.

References leave().

Conexus::IPv4::UDP::CONEXUS_ENDPOINT_GENERIC_CREATE (  ) 

Reimplemented in Conexus::IPv4::UDPPoset.

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

Reimplemented from Conexus::IPv4::IP.

Reimplemented in Conexus::IPv4::UDPPoset.

References Conexus::IPv4::IP::connect().

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

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

UDP::pointer Conexus::IPv4::UDP::create ( uint32_t  local_if,
uint16_t  localport,
uint16_t  remoteport 
) [static]

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

unsigned int Conexus::IPv4::UDP::default_multicast_hops (  )  [static]

References m_default_hops.

bool Conexus::IPv4::UDP::default_multicast_loopback (  )  [static]

References m_default_loopback.

size_t Conexus::IPv4::UDP::input_available (  )  throw () [virtual]

Reimplemented from Conexus::Endpoint.

References Conexus::FileDescriptor::m_fd.

bool Conexus::IPv4::UDP::is_multicast_interface ( const std::string &  iface_name  ) 

bool Conexus::IPv4::UDP::is_multicast_interface ( unsigned  iface_index  ) 

void Conexus::IPv4::UDP::join ( unsigned  interface  )  [protected, virtual]

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

Issues a join on all multicast interfaces.

If no interfaces have been specified, then the join is issued on the system default.

References Conexus::Socket::is_bound(), Conexus::IPv4::Address::is_multicast(), Conexus::IPv4::IP::m_local_address, and m_multicast_interfaces.

Referenced by add_multicast_interface(), bind(), and connect().

void Conexus::IPv4::UDP::leave ( unsigned  interface  )  [protected, virtual]

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

Issues a leave on all multicast interfaces.

If no interfaces have been specified, then the leave is issued on the system default.

References Conexus::Socket::is_bound(), Conexus::IPv4::Address::is_multicast(), Conexus::IPv4::IP::m_local_address, and m_multicast_interfaces.

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

unsigned Conexus::IPv4::UDP::multicast_hops (  )  [virtual]

Returns the multicast ttl of the currently associated address.

References Conexus::Socket::is_bound(), m_multicast_hops, and Conexus::Socket::option().

bool Conexus::IPv4::UDP::multicast_loopback (  )  [virtual]

If true multicast packets are looped back to local sockets.

References Conexus::Socket::is_bound(), m_multicast_loopback, and Conexus::Socket::option().

void Conexus::IPv4::UDP::on_local_address_changed (  )  [protected, virtual]

void Conexus::IPv4::UDP::on_remote_address_changed (  )  [protected, virtual]

int Conexus::IPv4::UDP::output_pending (  )  [virtual]

Returns the size in bytes of the local send queue.

References Conexus::FileDescriptor::m_fd.

void Conexus::IPv4::UDP::remove_multicast_interface ( const std::string &  iface_name  ) 

void Conexus::IPv4::UDP::remove_multicast_interface ( unsigned  iface_index  ) 

void Conexus::IPv4::UDP::set_default_multicast_hops ( unsigned int  hops  )  [static]

void Conexus::IPv4::UDP::set_default_multicast_loopback ( bool  loopback  )  [static]

void Conexus::IPv4::UDP::set_multicast_hops ( unsigned  hops  )  [virtual]

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

References Conexus::Socket::is_bound(), m_multicast_hops, and Conexus::Socket::set_option().

void Conexus::IPv4::UDP::set_multicast_loopback ( bool  loopback  )  [virtual]

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

References Conexus::Socket::is_bound(), m_multicast_loopback, and Conexus::Socket::set_option().

void Conexus::IPv4::UDP::set_suppress_multicast_join ( bool  value = true  )  [virtual]

void Conexus::IPv4::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.

Reimplemented in Conexus::IPv4::UDPPoset.

References m_write_without_connect.

bool Conexus::IPv4::UDP::suppress_multicast_join (  )  const [virtual]

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

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

Reimplemented from Conexus::Socket.

Reimplemented in Conexus::IPv4::UDPPoset.

References Conexus::ENDPOINT_OPENED, Conexus::SOCKET_CONNECTED, Conexus::Socket::write_data(), and Conexus::Socket::writeto().

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


Member Data Documentation

unsigned int Conexus::IPv4::UDP::m_default_hops = DEFAULT_IPV4_MULTICAST_HOPS [static, protected]

All data output on this socket is accumulated into a single datagram that is transmitted when the socket is uncorked.

All data output on this socket is accumulated into a single datagram that is transmitted when the socket is uncorked.

Referenced by default_multicast_hops(), and set_default_multicast_hops().

bool Conexus::IPv4::UDP::m_default_loopback = DEFAULT_IPV4_MULTICAST_LOOP_BACK [static, protected]

std::set<unsigned> Conexus::IPv4::UDP::m_multicast_interfaces [protected]


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

Generated on Tue Mar 3 09:48:09 2009 for conexus by doxygen 1.5.7.1