dht::SockAddr Class Reference

`#include <sockaddr.h>`

## Classes

struct | ipCmp

## Public Member Functions

| SockAddr (const SockAddr &o)
| SockAddr (SockAddr &&o)
| SockAddr (const sockaddr *sa, socklen_t length)
| SockAddr (const sockaddr *sa)
| SockAddr (const sockaddr_storage &ss, socklen_t len)
bool | operator< (const SockAddr &o) const
bool | equals (const SockAddr &o) const
SockAddr & | operator= (const SockAddr &o)
SockAddr & | operator= (SockAddr &&o)
std::string | toString () const
sa_family_t | getFamily () const
void | setFamily (sa_family_t af)
in_port_t | getPort () const
void | setPort (in_port_t p)
socklen_t | getLength () const
| operator bool () const noexcept
const sockaddr * | get () const
sockaddr * | get ()
const sockaddr_in & | getIPv4 () const
const sockaddr_in6 & | getIPv6 () const
sockaddr_in & | getIPv4 ()
sockaddr_in6 & | getIPv6 ()
bool | isLoopback () const
bool | isPrivate () const
bool | isUnspecified () const
bool | isMappedIPv4 () const
SockAddr | getMappedIPv4 () const

## Static Public Member Functions

static std::vector< SockAddr > | resolve (const std::string &host, const std::string &service={})

## Detailed Description

A Socket Address (sockaddr*), with abstraction for IPv4, IPv6 address families.

Definition at line 55 of file sockaddr.h.

## Constructor & Destructor Documentation

## SockAddr() [1/6]

dht::SockAddr::SockAddr | ( |  | ) |

inline

Definition at line 57 of file sockaddr.h.

## SockAddr() [2/6]

dht::SockAddr::SockAddr | ( | const SockAddr & | o | ) |

inline

Definition at line 58 of file sockaddr.h.

## SockAddr() [3/6]

dht::SockAddr::SockAddr | ( | SockAddr && | o | ) |

inline

Definition at line 61 of file sockaddr.h.

## SockAddr() [4/6]

dht::SockAddr::SockAddr | ( | const sockaddr * | sa,
|  | socklen_t | length
| ) |  |

inline

Build from existing address.

Definition at line 68 of file sockaddr.h.

## SockAddr() [5/6]

dht::SockAddr::SockAddr | ( | const sockaddr * | sa | ) |

inline

Definition at line 73 of file sockaddr.h.

## SockAddr() [6/6]

dht::SockAddr::SockAddr | ( | const sockaddr_storage & | ss,
|  | socklen_t | len
| ) |  |

inline

Build from an existing sockaddr_storage structure.

Definition at line 89 of file sockaddr.h.

## Member Function Documentation

## equals()

bool dht::SockAddr::equals | ( | const SockAddr & | o | ) | const

inline

Definition at line 99 of file sockaddr.h.

## get() [1/2]

sockaddr * dht::SockAddr::get | ( |  | ) |

inline

Returns the address to the managed sockaddr structure. The accessible length is returned by getLength().

Definition at line 201 of file sockaddr.h.

## get() [2/2]

const sockaddr * dht::SockAddr::get | ( |  | ) | const

inline

Returns the address to the managed sockaddr structure. The accessible length is returned by getLength().

Definition at line 195 of file sockaddr.h.

## getFamily()

sa_family_t dht::SockAddr::getFamily | ( |  | ) | const

inline

Returns the address family or AF_UNSPEC if the address is not set.

Definition at line 121 of file sockaddr.h.

## getIPv4() [1/2]

sockaddr_in & dht::SockAddr::getIPv4 | ( |  | ) |

inline

Definition at line 209 of file sockaddr.h.

## getIPv4() [2/2]

const sockaddr_in & dht::SockAddr::getIPv4 | ( |  | ) | const

inline

Definition at line 203 of file sockaddr.h.

## getIPv6() [1/2]

sockaddr_in6 & dht::SockAddr::getIPv6 | ( |  | ) |

inline

Definition at line 212 of file sockaddr.h.

## getIPv6() [2/2]

const sockaddr_in6 & dht::SockAddr::getIPv6 | ( |  | ) | const

inline

Definition at line 206 of file sockaddr.h.

## getLength()

socklen_t dht::SockAddr::getLength | ( |  | ) | const

inline

Returns the accessible byte length at the pointer returned by get(). If zero, get() returns null.

Definition at line 182 of file sockaddr.h.

## getPort()

in_port_t dht::SockAddr::getPort | ( |  | ) | const

inline

Retreive the port (in host byte order) or 0 if the address is not of a supported family.

Definition at line 153 of file sockaddr.h.

## isLoopback()

bool dht::SockAddr::isLoopback | ( |  | ) | const

Return true if address is a loopback IP address.

## isPrivate()

bool dht::SockAddr::isPrivate | ( |  | ) | const

Return true if address is not a public IP address.

## operator bool()

dht::SockAddr::operator bool | ( |  | ) | const

inline explicit noexcept

An address is defined to be true if its length is not zero.

Definition at line 187 of file sockaddr.h.

## operator<()

bool dht::SockAddr::operator< | ( | const SockAddr & | o | ) | const

inline

Definition at line 93 of file sockaddr.h.

## operator=() [1/2]

SockAddr & dht::SockAddr::operator= | ( | const SockAddr & | o | ) |

inline

Definition at line 103 of file sockaddr.h.

## operator=() [2/2]

SockAddr & dht::SockAddr::operator= | ( | SockAddr && | o | ) |

inline

Definition at line 107 of file sockaddr.h.

## setFamily()

void dht::SockAddr::setFamily | ( | sa_family_t | af | ) |

inline

Resize the managed structure to the appropriate size (if needed), in which case the sockaddr structure is cleared to zero, and set the address family field (sa_family).

Definition at line 128 of file sockaddr.h.

## setPort()

void dht::SockAddr::setPort | ( | in_port_t | p | ) |

inline

Set the port. The address must be of a supported family.

Parameters

  p | The port in host byte order.

Definition at line 167 of file sockaddr.h.

## toString()

std::string dht::SockAddr::toString | ( |  | ) | const

inline

Definition at line 114 of file sockaddr.h.

The documentation for this class was generated from the following file:

- /tmp/slackbuilds_libs/opendht-1.7.4/include/opendht/sockaddr.h