net/IPv4Address: add method GetPortBE()

This commit is contained in:
Max Kellermann 2021-11-24 17:47:39 +01:00 committed by Max Kellermann
parent 868f1a4431
commit c30466b84a

View File

@ -187,11 +187,18 @@ public:
return address.sin_family != AF_UNSPEC;
}
/**
* @return the port number in network byte order
*/
constexpr uint16_t GetPortBE() const noexcept {
return address.sin_port;
}
/**
* @return the port number in host byte order
*/
constexpr uint16_t GetPort() const noexcept {
return FromBE16(address.sin_port);
return FromBE16(GetPortBE());
}
/**