Class EndPointAddress
Defined in File Netio3Backend.hpp
Class Documentation
-
class EndPointAddress
Class containing the IP address and port of a network endpoint.
The IP is stored as a string and as a numeric value for faster comparisons.
Public Functions
-
EndPointAddress() = default
-
EndPointAddress(const std::string &ip, unsigned short port)
Construct an EndPointAddress object from an IP address and port.
- Parameters:
ip – IP address
port – Port number
-
explicit EndPointAddress(const std::string &str)
Construct an EndPointAddress object from a string containing the IP address and port.
Format of the string: “IP:port” or “IP” (assumes port 0)
- Parameters:
str – String containing the IP address and port
-
inline const std::string &address() const
Get the IP address.
- Returns:
IP address
-
inline unsigned short port() const
Get the port.
- Returns:
Port number
-
inline std::uint32_t address_numeric() const
Get the IP address as a numeric value.
- Returns:
IP address as a numeric value
-
inline void port(unsigned short port)
Set the IP address.
- Parameters:
ip – IP address
-
inline auto operator<=>(const EndPointAddress &other) const
Compare two EndPointAddress objects using numeric IP and port.
- Parameters:
other – EndPointAddress object to compare with
- Returns:
Comparison result
-
inline bool operator==(const EndPointAddress &other) const
Compare two EndPointAddress objects for equality using numeric IP and port.
- Parameters:
other – EndPointAddress object to compare with
- Returns:
Comparison result
-
inline bool operator!=(const EndPointAddress &other) const
Compare two EndPointAddress objects for inequality using numeric IP and port.
- Parameters:
other – EndPointAddress object to compare with
- Returns:
Comparison result
Friends
-
friend std::ostream &operator<<(std::ostream&, const EndPointAddress&)
Overload the << operator to print the IP address and port.
- Parameters:
stream – Output stream
val – EndPointAddress object
- Returns:
Output stream
-
template<typename H>
inline friend H AbslHashValue(H h, const EndPointAddress &endpoint) Enable hashing with absl::Hash.
- Template Parameters:
H – Hash state type
- Parameters:
h – Current hash state
endpoint – EndPointAddress to hash
- Returns:
Updated hash state
-
EndPointAddress() = default