Endpoint

#include <kademlia/endpoint.hpp>

class kademlia::endpoint

Represents a network enpoint.

This class is used to:

Constructors

endpoint(void)

Construct an unitialized endpoint.

endpoint(address_type const &address, service_type const &service)

Constructs an endpoint from an address and a port service identifier.

endpoint(address_type const &address, service_numeric_type const &service)

Constructs an endpoint from an address and a port service identifier.

Methods

address_type const &address(void) const

Get the address of the enpoint.

void address(address_type const &address)

Set the address of the enpoint.

service_type const &service(void) const

Get the service of the enpoint.

void service(service_type const &service)

Set the service of the enpoint.

Types

using address_type = std::string

Represents an address.

It can be:

  • An IPv4 (e.g. "192.168.1.1")

  • An IPv6 (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334")

  • A hostname (e.g. "host-7430")

using service_type = std::string

Represents a port.

It can be:

  • An unsigned 16 bits integer (e.g. "12345")

  • A protocol name (e.g. "http")

using service_numeric_type = std::uint16_t

Represents a port as a 16 bits unsigned integer.

Helpers

std::ostream &operator<<(std::ostream &out, endpoint const &e)

Print the endpoint e string representation into the stream out.

std::istream &operator>>(std::istream &in, endpoint &e)

Parse the endpoint e string representation from the stream in.

bool operator==(endpoint const &a, endpoint const &b)

Compare endpoints a & b for equality.

Return true if they are equal, false otherwise

bool operator!=(endpoint const &a, endpoint const &b)

Compare endpoints a & b for inequality.

Return true if they aren’t equal, false otherwise