18 explicit operator bool()
const {
return ipv4 != 0 && port != 0; }
20 bool operator==(
const NetAddress& other)
const {
21 return ipv4 == other.
ipv4 && port == other.port;
23 bool operator!=(
const NetAddress& other)
const {
return !(*
this == other); }
46 static bool parsePort(
const std::string& text, uint16_t& port);
Where a datagram came from, or is going to: an IPv4 host and a port.
Definition net_address.h:13
static NetAddress parse(const std::string &text, uint16_t fallbackPort=0)
Read "host:port", or "host" with fallbackPort.
uint32_t ipv4
Host byte order: 0x7F000001 is 127.0.0.1.
Definition net_address.h:14
std::string toString() const
"127.0.0.1:27015", for a log line or a readout.
static bool parsePort(const std::string &text, uint16_t &port)
Read a port: decimal digits and nothing else, 1 to 65535.