dodo
0.0.1
A C++ library to create containerized Linux services
|
Go to the documentation of this file.
23 #ifndef network_address_hpp
24 #define network_address_hpp
26 #include <arpa/inet.h>
32 #include <sys/socket.h>
103 Address(
const std::string &ip, uint16_t port );
109 Address(
const std::string &ip );
115 Address(
const sockaddr_storage& address );
122 Address(
const sockaddr *address, socklen_t len );
141 std::string
asString(
bool withport =
false )
const;
229 std::string &canonicalname );
326 std::stringstream ss;
uint16_t getPort() const
Return the port number.
Address & operator=(const std::string &address)
Assign from "ip" string.
common::SystemError getNameInfo(std::string &hostname) const
Do a reverse DNS lookup on this Address and return in hostname.
bool isValid() const
True if this Address is valid.
Interface to objects that support dumping their state to a string.
std::string asString(bool withport=false) const
Return a string representation of this Address.
std::string canonicalname
The canonical name for a host.
SocketParams::AddressFamily getAddressFamily() const
Get this Address family.
AddressFamily
Addres family type.
Generic network Address, supporting ipv4 and ipv6 transparently.
static common::SystemError getHostAddrInfo(const std::string &hostname, AddrInfo &info)
Get Address information on a host in a AddrInfo struct.
std::list< AddrInfoItem > items
AddrInfoItem list for the host.
Address()
Construct an invalid (unspecified) address.
void setPort(uint16_t port)
Set the port number.
void init()
Initialize the internals.
Socket parameters - the family (domain), socket type and protocol triplet.
struct sockaddr_in6 * asIPv6Address() const
Explicit cast of addr_ as sockaddr_in6*.
struct sockaddr_in * asIPv4Address() const
Explicit cast of addr_ as sockaddr_in*.
std::string asString() const
Return the parameters as a string.
Interface for network communication.
bool operator==(const Address &address) const
Test for equality.
Address address
The Address of this item.
const sockaddr_storage * getAddress() const
Get to the underlying sockaddr_storage.
Linux system error primitive to provide a consistent interface to Linux error codes.
struct sockaddr_storage addr_
The address storage (for either ipv4 or ipv6).
SocketParams params
The SocketParams for this item.
Address info, comprising the canonical name of a host, and list of address info items for the host.
Address info item as used in AddrInfo.
Interface to and common implementation of concrete sockets (Socket, TLSSocket).
std::string asString()
String representation.