Socket_Address

class Socket_Address

A simple place to store and manipulate tcp and port address for communication layer

Inheritance diagram

Inheritance diagram of Socket_Address

unsigned long int GetIPAddressRaw(void) const

Returns a raw 32-bit unsigned integer representing the IPv4 address.

Deprecated: Does not work with IPv6 addresses.

explicit Socket_Address(unsigned short int port = 0)
Socket_Address(Socket_Address const &inaddr)

Constructor that lets us set a port value

void clear(void)

Set the internal values to a suitable known value

sa_family_t get_family(void) const

Returns AF_INET if this is an IPv4 address, or AF_INET6 if this is an IPv6 address.

std::string get_ip(void) const

Return the IP address portion in dot notation string.

std::string get_ip_port(void) const

Return the ip address/port in dot notation string. If this is an IPv6 address, it will be enclosed in square brackets.

unsigned short int get_port(void) const

Get the port portion as an integer

bool is_any(void) const

True if the address is zero.

bool is_mcast_range(void) const

True if the address is in the multicast range.

bool set_any_IP(unsigned short int port)

Set to any address and a specified port

bool set_any_IPv6(unsigned short int port)

Set to any IPv6 address and a specified port.

bool set_broadcast(unsigned short int port)

Set to the broadcast address and a specified port

bool set_host(std::string const &hostname, unsigned short int port)
bool set_host(std::string const &hostname)
bool set_host(uint32_t ip4addr, unsigned short int 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.

Initializes the address from a string specifying both the address and port, separated by a colon. An IPv6 address must be enclosed in brackets.

bool set_port(unsigned short int port)

Set to a specified port