#include <udp.h>
Public Types | |
typedef ConexusPointer< UDP > | pointer |
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 |
typedef ConexusPointer<UDP> Conexus::NSPR::UDP::pointer |
Reimplemented from Conexus::NSPR::Socket.
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.
void Conexus::NSPR::UDP::bind | ( | Conexus::Address & | a | ) | throw ( bind_exception ) [virtual] |
References Conexus::NSPR::Socket::bind().
void Conexus::NSPR::UDP::bind | ( | ) | throw ( bind_exception ) [virtual] |
Reimplemented from Conexus::NSPR::Socket.
References Conexus::IPv4::Address::is_multicast(), join(), Conexus::NSPR::Socket::m_local_address, m_multicast_auto_join, and Conexus::IPv4::Address::port().
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] |
References Conexus::NSPR::Socket::connect().
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] |
void Conexus::NSPR::UDP::leave | ( | ) | [protected, virtual] |
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] |
Reimplemented from Conexus::NSPR::Socket.
References Conexus::ENDPOINT_OPENED, Conexus::SOCKET_CONNECTED, Conexus::NSPR::Socket::write_data(), and Conexus::NSPR::Socket::writeto().
bool Conexus::NSPR::UDP::write_without_connect | ( | ) | const [virtual] |
References m_write_without_connect.
bool Conexus::NSPR::UDP::m_multicast_auto_join [protected] |
Referenced by bind(), multicast_auto_join(), and set_multicast_auto_join().
bool Conexus::NSPR::UDP::m_multicast_joined [protected] |
bool Conexus::NSPR::UDP::m_write_without_connect [protected] |
Referenced by set_write_without_connect(), and write_without_connect().