boost::corosio::endpoint

An IP endpoint (address + port) supporting both IPv4 and IPv6.

Synopsis

class endpoint;

Description

This class represents an endpoint for IP communication, consisting of either an IPv4 or IPv6 address and a port number. Endpoints are used to specify connection targets and bind addresses.

The endpoint holds both address types as separate members (not a union), with a discriminator to track which address type is active.

Thread Safety

Distinct objects: Safe. Shared objects: Safe.

Example

// IPv4 endpoint
endpoint ep4(ipv4_address::loopback(), 8080);

// IPv6 endpoint
endpoint ep6(ipv6_address::loopback(), 8080);

// Port only (defaults to IPv4 any address)
endpoint bind_addr(8080);

// Parse from string
endpoint ep;
if (auto ec = parse_endpoint("192.168.1.1:8080", ep); !ec) {
    // use ep
}

Member Functions

Name

Description

endpoint [constructor]

Constructors

is_v4

Check if this endpoint uses an IPv4 address.

is_v6

Check if this endpoint uses an IPv6 address.

port

Get the port number.

v4_address

Get the IPv4 address.

v6_address

Get the IPv6 address.

Friends

Name Description

boost::corosio::operator!=

Compare endpoints for inequality.

boost::corosio::operator==

Compare endpoints for equality.

Created with MrDocs