Conexus::IPv4::UDP Class Reference
[Classes for communicating via IP version 4 sockets]

#include <conexus/ipv4_udp.h>

Inheritance diagram for Conexus::IPv4::UDP:

Inheritance graph
[legend]
List of all members.

Detailed Description

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

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


Public Types

typedef boost::shared_ptr<
UDP
pointer

Public Member Functions

 UDP (uint16_t localport=0, uint16_t remoteport=0)
virtual void bind () throw ( bind_error )
virtual void bind (Conexus::Address &a) throw ( bind_error )
virtual void close () throw ( close_error )
virtual int pending_input_datagram_size ()
 Returns the size in bytes of the next pending datagram, or 0 when no datagram is pending.
virtual int pending_output_datagram_size ()
 Returns the size in bytes of the local send queue.
virtual ssize_t write (const void *data, size_t size) throw ( write_error )
 Overloads the Socket ancestor send method to ensure that the socket is connected before trying to send.
virtual Data read (size_t s=-1) throw ( read_error )
 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.
virtual void connect () throw ( connect_error )
virtual void connect (Address &a) throw ( connect_error )
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.
virtual const std::string & object_type ()

Static Public Member Functions

static UDP::pointer create (uint16_t localport=0, uint16_t remoteport=0)

Protected Member Functions

virtual void join ()
 Joins the multicast group specified by addr.
virtual void leave ()
 Leaves the multicast group specified by addr.
virtual void on_local_interface_changed (unsigned which)
virtual void on_remote_address_changed (unsigned which)

Protected Attributes

bool m_write_without_connect
bool m_multicast_auto_join
ip_mreq * m_multicast_request


Member Function Documentation

Data Conexus::IPv4::UDP::read size_t  s = -1  )  throw ( read_error ) [virtual]
 

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::Socket.

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 error. 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 errors.

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

Reimplemented in Conexus::IPv4::UDPPoset.


The documentation for this class was generated from the following files:
Generated on Sat Aug 26 17:35:26 2006 by  doxygen 1.4.6