32 using namespace std::string_literals;
36 ip_address::ip_address(std::string address, uint16_t port) : m_addr{std::move(address)}, m_port{port}
52 auto const *
const end =
value + ::strnlen(
value, 22);
57 for (
auto *iter =
value; iter != end; ++iter) {
58 if (std::isspace(*iter))
59 throw std::runtime_error{
"Spaces are not permitted in IP address strings" +
63 }
else if (*iter ==
':') {
65 throw std::runtime_error{
"Invalid ip address: \""s +
value +
66 "\" expected 4 octets before the port number %u" +
71 port = ::strtoul(iter + 1,
nullptr, 10);
72 if (port > UINT16_MAX) {
73 throw std::runtime_error{
"Invalid ip address: \""s +
value +
81 throw std::runtime_error{
"Invalid ip address: \""s +
value +
"\""};
uint16_t get_port() const noexcept
std::string const & get_address() const noexcept
std::string to_string(storage::control::message_type type)
ip_address parse_ip_v4_address(char const *value)