Skip to content

feat: add a generic ip_address type #357

Description

@sgerbino

From the linked review feedback ("Some thoughts on Corosio", Boost mailing list, July 2026):

I noticed that there's no generic ip_address type capable of holding either an IPv4 or an IPv6 address. The closest equivalent is corosio::endpoint, which also hold a port and is therefore not a suitable replacement.

Source: https://lists.boost.org/archives/list/boost%40lists.boost.org/message/KHNY67ZNXFWT54EIWDOJPHN4KO6KJLN4 (referenced by the Boost review result, September 2026).

endpoint already holds both ipv4_address and ipv6_address with a discriminator, so this is an extraction rather than an addition: ip_address comes out of endpoint, and endpoint reduces to ip_address + port.

Core (this issue):

  • ip_address: implicit construction from ipv4_address/ipv6_address, family predicates, family-generic is_loopback()/is_multicast()/is_unspecified(), string parsing (address without port), comparison
  • Conversion accessors to ipv4_address/ipv6_address: prefer a result/optional style over Asio's throwing bad_address_cast
  • Decide v4-mapped v6 semantics (is_v4_mapped(), to_v4_mapped(), whether mapped forms compare equal to their v4 form) and centralize the existing ad hoc handling in native/detail/endpoint_convert.hpp
  • Refactor endpoint onto ip_address + port with a single address() accessor; keep the existing ipv4_address/ipv6_address constructors working via implicit conversion; decide the fate of v4_address()/v6_address()

Follow-ons (separate issues once the core lands):

  • Deduplicate the multicast socket options (join_group/join_group_v6, multicast_loop/multicast_loop_v6, ...) behind ip_address-taking options
  • Host-only resolution returning ip_addresses (resolver results currently can only express address + port)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

  • Status
    In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions