A simple place to store and manipulate tcp and port address for communication layer. More...
#include "socket_address.h"
Public Member Functions | |
Socket_Address (const struct sockaddr &inaddr) | |
Socket_Address (const struct sockaddr_in &inaddr) | |
Socket_Address (const struct sockaddr_in6 &inaddr) | |
Socket_Address (const struct sockaddr_storage &inaddr) | |
Socket_Address (unsigned short port=0) | |
Constructor that lets us set a port value. More... | |
Socket_Address (const Socket_Address &inaddr) | |
virtual | ~Socket_Address () |
Normal Destructor. More... | |
void | clear () |
Set the internal values to a suitable known value. More... | |
sa_family_t | get_family () const |
Returns AF_INET if this is an IPv4 address, or AF_INET6 if this is an IPv6 address. More... | |
std::string | get_ip () const |
Return the IP address portion in dot notation string. More... | |
std::string | get_ip_port () const |
Return the ip address/port in dot notation string. More... | |
unsigned short | get_port () const |
Get the port portion as an integer. More... | |
struct sockaddr & | GetAddressInfo () |
const struct sockaddr & | GetAddressInfo () const |
unsigned long | GetIPAddressRaw () const |
Returns a raw 32-bit unsigned integer representing the IPv4 address. More... | |
bool | is_any () const |
True if the address is zero. More... | |
bool | is_mcast_range () const |
True if the address is in the multicast range. More... | |
bool | operator != (const Socket_Address &in) const |
bool | operator< (const Socket_Address &in) const |
bool | operator== (const Socket_Address &in) const |
bool | set_any_IP (unsigned short port) |
Set to any address and a specified port. More... | |
bool | set_any_IPv6 (unsigned short port) |
Set to any IPv6 address and a specified port. More... | |
bool | set_broadcast (unsigned short port) |
Set to the broadcast address and a specified port. More... | |
bool | set_host (const std::string &hostname, unsigned short port) |
This function will take a port and string-based TCP address and initialize the address with this information. More... | |
bool | set_host (const std::string &hostname) |
Initializes the address from a string specifying both the address and port, separated by a colon. More... | |
bool | set_host (uint32_t ip4addr, unsigned short port) |
bool | set_port (unsigned short port) |
Set to a specified port. More... | |
A simple place to store and manipulate tcp and port address for communication layer.
Definition at line 25 of file socket_address.h.
|
inlineexplicit |
Constructor that lets us set a port value.
Definition at line 20 of file socket_address.I.
|
inlinevirtual |
Normal Destructor.
Definition at line 85 of file socket_address.I.
|
inline |
Set the internal values to a suitable known value.
Definition at line 168 of file socket_address.I.
Referenced by NetAddress::clear().
|
inline |
Returns AF_INET if this is an IPv4 address, or AF_INET6 if this is an IPv6 address.
Definition at line 179 of file socket_address.I.
Referenced by Socket_TCP::ActiveOpen(), Socket_TCP::ActiveOpenNonBlocking(), Socket_UDP_Incoming::OpenForInput(), Socket_UDP_Incoming::OpenForInputMCast(), and Socket_TCP_Listen::OpenForListen().
std::string Socket_Address::get_ip | ( | ) | const |
Return the IP address portion in dot notation string.
Definition at line 90 of file socket_address.cxx.
Referenced by NetAddress::get_ip_string().
std::string Socket_Address::get_ip_port | ( | ) | const |
Return the ip address/port in dot notation string.
If this is an IPv6 address, it will be enclosed in square brackets.
Definition at line 112 of file socket_address.cxx.
References get_port().
|
inline |
Get the port portion as an integer.
Definition at line 187 of file socket_address.I.
Referenced by get_ip_port(), NetAddress::get_port(), and Socket_UDP_Incoming::OpenForInputMCast().
unsigned long Socket_Address::GetIPAddressRaw | ( | ) | const |
Returns a raw 32-bit unsigned integer representing the IPv4 address.
Definition at line 138 of file socket_address.cxx.
Referenced by NetAddress::get_ip().
|
inline |
True if the address is zero.
Definition at line 235 of file socket_address.I.
Referenced by NetAddress::is_any().
|
inline |
True if the address is in the multicast range.
Definition at line 251 of file socket_address.I.
|
inline |
Set to any address and a specified port.
Definition at line 136 of file socket_address.I.
Referenced by NetAddress::set_any().
|
inline |
Set to any IPv6 address and a specified port.
Definition at line 147 of file socket_address.I.
|
inline |
Set to the broadcast address and a specified port.
Definition at line 125 of file socket_address.I.
Referenced by NetAddress::set_broadcast(), and set_host().
bool Socket_Address::set_host | ( | const std::string & | hostname, |
unsigned short | port | ||
) |
This function will take a port and string-based TCP address and initialize the address with this information.
Returns true on success; on failure, it returns false and the address may be undefined.
Definition at line 23 of file socket_address.cxx.
References set_broadcast().
Referenced by NetAddress::set_host(), set_host(), and NetAddress::set_localhost().
bool Socket_Address::set_host | ( | const std::string & | hostname | ) |
Initializes the address from a string specifying both the address and port, separated by a colon.
An IPv6 address must be enclosed in brackets.
Definition at line 51 of file socket_address.cxx.
References set_host().
|
inline |
Set to a specified port.
Definition at line 159 of file socket_address.I.
Referenced by NetAddress::set_port().