#include <ipv4_udp.h>
Public Types | |
typedef ConexusPointer< UDP > | pointer |
Public Member Functions | |
CONEXUS_ENDPOINT_GENERIC_CREATE () | |
virtual | ~UDP () throw () |
Automatically leaves any multicast groups this endpoint has joined. | |
virtual size_t | input_available () throw () |
Returns the amount of input currently available for reading. | |
virtual void | bind () throw ( bind_exception ) |
Binds the UDP endpoint to the local address. | |
virtual void | bind (const Conexus::Address &a) throw ( bind_exception ) |
Sets the local address to the given parameter and binds the endpoint. | |
virtual void | close () throw ( close_exception ) |
Closes the endpoint. | |
virtual int | output_pending () |
Returns the size in bytes of the local send queue. | |
virtual void | connect () throw ( connect_exception ) |
Connects the endpoint to the currently set remote address. | |
virtual void | connect (const Address &a) throw ( connect_exception ) |
Sets the remote address to the given parameter and connects to the given address. | |
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_hop_limit () |
Returns the multicast ttl of the currently associated address. | |
virtual void | set_multicast_hop_limit (unsigned hop_limit) |
Sets the multicast ttl of the currently associated address to hop_limit. | |
virtual bool | is_multicast_loopback_enabled () |
If true multicast packets are looped back to local sockets. | |
virtual void | enable_multicast_loopback (bool enable) |
If parameter enable 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) |
Creates a UDP endpoint on the default local interface with the given local and remote ports. | |
static pointer | create (uint32_t local_if, uint16_t localport, uint16_t remoteport) |
Creates a UDP endpoint on the specified local interface with the given local and remote ports. | |
static pointer | create (const std::string &local_if, uint16_t localport=0, uint16_t remoteport=0) |
Creates a UDP endpoint on the named local interface with the given local and remote ports. | |
static unsigned int | default_multicast_hop_limit () |
static void | set_default_multicast_hop_limit (unsigned int hop_limit) |
static bool | is_default_multicast_loopback_enabled () |
static void | enable_default_multicast_loopback (bool loopback) |
Protected Member Functions | |
UDP (uint32_t local_if, uint16_t localport, uint16_t remoteport, int proto=IPPROTO_UDP) | |
UDP (const std::string &local_if, uint16_t localport, uint16_t remoteport, int proto=IPPROTO_UDP) | |
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_hop_limit |
bool | m_multicast_loopback_enabled |
Static Protected Attributes | |
static unsigned int | m_default_hop_limit = DEFAULT_IPV4_MULTICAST_HOPS |
static bool | m_default_loopback_enabled = DEFAULT_IPV4_MULTICAST_LOOP_BACK |
factory_client.cpp, factory_server.cpp, registry_client.cpp, and registry_server.cpp.
typedef ConexusPointer<UDP> Conexus::IPv4::UDP::pointer |
Reimplemented from Conexus::IPv4::IP.
Reimplemented in Conexus::IPv4::UDPPoset, and Conexus::SSL::IPv4::UDP.
Conexus::IPv4::UDP::UDP | ( | uint32_t | local_if, | |
uint16_t | localport, | |||
uint16_t | remoteport, | |||
int | proto = IPPROTO_UDP | |||
) | [protected] |
Conexus::IPv4::UDP::UDP | ( | const std::string & | local_if, | |
uint16_t | localport, | |||
uint16_t | remoteport, | |||
int | proto = IPPROTO_UDP | |||
) | [protected] |
Conexus::IPv4::UDP::~UDP | ( | ) | throw () [virtual] |
Automatically leaves any multicast groups this endpoint has joined.
Reimplemented in Conexus::SSL::IPv4::UDP.
References leave().
void Conexus::IPv4::UDP::add_multicast_interface | ( | const std::string & | iface_name | ) |
References add_multicast_interface(), and Conexus::Network::interface_index().
void Conexus::IPv4::UDP::add_multicast_interface | ( | unsigned | iface_index | ) |
References Conexus::Socket::is_bound(), join(), and m_multicast_interfaces.
Referenced by add_multicast_interface().
void Conexus::IPv4::UDP::bind | ( | const Conexus::Address & | a | ) | throw ( bind_exception ) [virtual] |
Sets the local address to the given parameter and binds the endpoint.
Reimplemented from Conexus::IPv4::IP.
Reimplemented in Conexus::IPv4::UDPPoset.
References Conexus::IPv4::IP::bind().
void Conexus::IPv4::UDP::bind | ( | ) | throw ( bind_exception ) [virtual] |
Binds the UDP endpoint to the local address.
Reimplemented from Conexus::IPv4::IP.
Reimplemented in Conexus::IPv4::UDPPoset.
References Conexus::IPv4::Address::is_broadcast(), Conexus::IPv4::Address::is_multicast(), join(), Conexus::IPv4::IP::m_local_address, m_multicast_hop_limit, m_multicast_loopback_enabled, m_suppress_multicast_join, and Conexus::Socket::set_option().
void Conexus::IPv4::UDP::close | ( | ) | throw ( close_exception ) [virtual] |
Conexus::IPv4::UDP::CONEXUS_ENDPOINT_GENERIC_CREATE | ( | ) |
Reimplemented in Conexus::IPv4::UDPPoset.
void Conexus::IPv4::UDP::connect | ( | const Address & | a | ) | throw ( connect_exception ) [virtual] |
Sets the remote address to the given parameter and connects to the given address.
Reimplemented from Conexus::IPv4::IP.
Reimplemented in Conexus::IPv4::UDPPoset, and Conexus::SSL::IPv4::UDP.
References Conexus::IPv4::IP::connect().
void Conexus::IPv4::UDP::connect | ( | ) | throw ( connect_exception ) [virtual] |
Connects the endpoint to the currently set remote address.
Reimplemented from Conexus::IPv4::IP.
Reimplemented in Conexus::IPv4::UDPPoset, and Conexus::SSL::IPv4::UDP.
References Conexus::IPv4::Address::is_multicast(), join(), Conexus::IPv4::IP::m_remote_address, and m_suppress_multicast_join.
Referenced by Conexus::SSL::IPv4::UDP::connect().
UDP::pointer Conexus::IPv4::UDP::create | ( | const std::string & | local_if, | |
uint16_t | localport = 0 , |
|||
uint16_t | remoteport = 0 | |||
) | [static] |
Creates a UDP endpoint on the named local interface with the given local and remote ports.
UDP::pointer Conexus::IPv4::UDP::create | ( | uint32_t | local_if, | |
uint16_t | localport, | |||
uint16_t | remoteport | |||
) | [static] |
Creates a UDP endpoint on the specified local interface with the given local and remote ports.
UDP::pointer Conexus::IPv4::UDP::create | ( | uint16_t | localport = 0 , |
|
uint16_t | remoteport = 0 | |||
) | [static] |
Creates a UDP endpoint on the default local interface with the given local and remote ports.
unsigned int Conexus::IPv4::UDP::default_multicast_hop_limit | ( | ) | [static] |
References m_default_hop_limit.
void Conexus::IPv4::UDP::enable_default_multicast_loopback | ( | bool | loopback | ) | [static] |
void Conexus::IPv4::UDP::enable_multicast_loopback | ( | bool | enable | ) | [virtual] |
If parameter enable is true then multicast packets are looped back to local sockets.
References Conexus::Socket::is_bound(), m_multicast_loopback_enabled, and Conexus::Socket::set_option().
size_t Conexus::IPv4::UDP::input_available | ( | ) | throw () [virtual] |
Returns the amount of input currently available for reading.
Reimplemented from Conexus::Endpoint.
References Conexus::FileDescriptor::m_fd.
bool Conexus::IPv4::UDP::is_default_multicast_loopback_enabled | ( | ) | [static] |
References m_default_loopback_enabled.
bool Conexus::IPv4::UDP::is_multicast_interface | ( | const std::string & | iface_name | ) |
References Conexus::Network::interface_index(), and is_multicast_interface().
bool Conexus::IPv4::UDP::is_multicast_interface | ( | unsigned | iface_index | ) |
bool Conexus::IPv4::UDP::is_multicast_loopback_enabled | ( | ) | [virtual] |
If true multicast packets are looped back to local sockets.
References Conexus::Socket::is_bound(), m_multicast_loopback_enabled, and Conexus::Socket::option().
void Conexus::IPv4::UDP::join | ( | unsigned | interface | ) | [protected, virtual] |
Issues a join on the local address for the specified interface.
References Conexus::Socket::is_bound(), Conexus::IPv4::Address::is_multicast(), Conexus::FileDescriptor::m_fd, Conexus::IPv4::IP::m_local_address, Conexus::IPv4::Address::sockaddr_in(), and Conexus::throw_socket_exception().
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] |
Issues a leave on the local address for the specified interface.
References Conexus::Socket::is_bound(), Conexus::IPv4::Address::is_multicast(), Conexus::IPv4::IP::m_local_address, Conexus::Socket::set_option(), and Conexus::IPv4::Address::sockaddr_in().
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_hop_limit | ( | ) | [virtual] |
Returns the multicast ttl of the currently associated address.
References Conexus::Socket::is_bound(), m_multicast_hop_limit, and Conexus::Socket::option().
void Conexus::IPv4::UDP::on_local_address_changed | ( | ) | [protected, virtual] |
Reimplemented from Conexus::IPv4::IP.
References Conexus::Endpoint::close_and_reopen(), and Conexus::Socket::is_bound().
void Conexus::IPv4::UDP::on_remote_address_changed | ( | ) | [protected, virtual] |
Reimplemented from Conexus::IPv4::IP.
References Conexus::Endpoint::close_and_reopen(), and Conexus::Socket::is_connected().
int Conexus::IPv4::UDP::output_pending | ( | ) | [virtual] |
void Conexus::IPv4::UDP::remove_multicast_interface | ( | const std::string & | iface_name | ) |
References Conexus::Network::interface_index(), and remove_multicast_interface().
void Conexus::IPv4::UDP::remove_multicast_interface | ( | unsigned | iface_index | ) |
References Conexus::Socket::is_bound(), leave(), and m_multicast_interfaces.
Referenced by remove_multicast_interface().
void Conexus::IPv4::UDP::set_default_multicast_hop_limit | ( | unsigned int | hop_limit | ) | [static] |
void Conexus::IPv4::UDP::set_multicast_hop_limit | ( | unsigned | hop_limit | ) | [virtual] |
Sets the multicast ttl of the currently associated address to hop_limit.
References Conexus::Socket::is_bound(), m_multicast_hop_limit, and Conexus::Socket::set_option().
void Conexus::IPv4::UDP::set_suppress_multicast_join | ( | bool | value = true |
) | [virtual] |
References m_suppress_multicast_join.
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] |
References m_suppress_multicast_join.
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, and Conexus::SSL::IPv4::UDP.
References Conexus::ENDPOINT_OPENED, Conexus::SOCKET_CONNECTED, Conexus::Socket::write_data(), and Conexus::Socket::writeto().
bool Conexus::IPv4::UDP::write_without_connect | ( | ) | const [virtual] |
References m_write_without_connect.
unsigned int Conexus::IPv4::UDP::m_default_hop_limit = DEFAULT_IPV4_MULTICAST_HOPS [static, protected] |
Referenced by default_multicast_hop_limit(), and set_default_multicast_hop_limit().
bool Conexus::IPv4::UDP::m_default_loopback_enabled = DEFAULT_IPV4_MULTICAST_LOOP_BACK [static, protected] |
Referenced by enable_default_multicast_loopback(), and is_default_multicast_loopback_enabled().
unsigned Conexus::IPv4::UDP::m_multicast_hop_limit [protected] |
Referenced by bind(), multicast_hop_limit(), and set_multicast_hop_limit().
std::set<unsigned> Conexus::IPv4::UDP::m_multicast_interfaces [protected] |
Referenced by add_multicast_interface(), is_multicast_interface(), join(), leave(), and remove_multicast_interface().
bool Conexus::IPv4::UDP::m_multicast_loopback_enabled [protected] |
Referenced by bind(), enable_multicast_loopback(), and is_multicast_loopback_enabled().
bool Conexus::IPv4::UDP::m_suppress_multicast_join [protected] |
Referenced by bind(), connect(), set_suppress_multicast_join(), and suppress_multicast_join().
bool Conexus::IPv4::UDP::m_write_without_connect [protected] |
Referenced by set_write_without_connect(), Conexus::IPv4::UDPPoset::UDPPoset(), and write_without_connect().