Skip to content

AInet4Address#

Represents an ipv4 address with port.

Header:#include <AUI/Network/AInet4Address.h>
CMake:aui_link(my_target PUBLIC aui::network)

Detailed Description#

AInet4Address is a small copyable value which is accepted by every socket class of aui::network. Use AInet4Address::fromString to build one from a dotted address or a hostname (resolved with the system resolver, throws AIOException if the name is unresolved) and AInet4Address::fromArray to build one from four octets.

auto server = AInet4Address::fromString("example.com", 80);
ALogger::info("Net") << "Connecting to " << server.toString(); // prints ip:port

The port is passed as the second argument and is stored along with the address. Addresses can be compared with ==, < and >, so they can be used as keys of AMap.

Warning

Only IPv4 is supported.

See TCP client and server and UDP datagrams and ping for usage with sockets.