LLFIO  v2.00
llfio_v2_xxx::ip Namespace Reference

Inspired by ASIO's ip namespace. More...

Classes

class  address
 A version independent IP address. More...
 
class  resolver
 Returned by resolve() as a handle to the asynchronous name resolution operation. More...
 
class  address_v4
 A v4 IP address. More...
 
class  address_v6
 Make an address_v6. v6 addresses need to have the form [::]:port. More...
 

Typedefs

using resolver_ptr = std::unique_ptr< resolver, detail::resolver_deleter >
 A pointer to a resolver.
 

Enumerations

enum class  family { unknown , v4 , v6 , any }
 The family of IP. More...
 
enum  bitfield__resolve_flag : unsigned { none = 0 , passive = (1U << 0U) , blocking = (1U << 1U) }
 Flags for resolve() More...
 

Functions

std::ostream & operator<< (std::ostream &s, const address &v)
 Write address to stream.
 
result< resolver_ptrresolve (string_view name, string_view service, family _family=family::any, deadline d={}, resolve_flag flags=resolve_flag::none) noexcept
 Retrieve a list of potential address for a given name and service e.g. "www.google.com" and "https" optionally within a bounded deadline. More...
 
result< size_t > resolve_trim_cache (size_t maxitems=64) noexcept
 resolve() may utilise a process-wide cache, if so this function will trim that cache.
 
result< address_v4make_address_v4 (string_view str) noexcept
 Make an address_v4
 
result< address_v4make_address_v4 (const address_v4::bytes_type &bytes, uint16_t port=0) noexcept
 Make an address_v4
 
result< address_v4make_address_v4 (const address_v4::uint_type &bytes, uint16_t port=0) noexcept
 Make an address_v4
 
result< address_v6make_address_v6 (string_view str) noexcept
 Make an address_v6
 
result< address_v6make_address_v6 (const address_v6::bytes_type &bytes, uint16_t port=0, uint32_t scope_id=0) noexcept
 Make an address_v6
 
result< addressmake_address (string_view str) noexcept
 Make a v4 or v6 address. v6 addresses need to have the form [::]:port.
 

Detailed Description

Inspired by ASIO's ip namespace.

Enumeration Type Documentation

◆ bitfield__resolve_flag

Flags for resolve()

Enumerator
none 

No flags.

passive 

Return addresses for binding to this machine.

blocking 

Execute address resolution synchronously.

223  {
224  none = 0, //!< No flags
225  passive = (1U << 0U), //!< Return addresses for binding to this machine.
226  blocking = (1U << 1U) //!< Execute address resolution synchronously.
227  } QUICKCPPLIB_BITFIELD_END(resolve_flag)
@ blocking
Execute address resolution synchronously.
Definition: byte_socket_handle.hpp:226
@ none
No flags.
Definition: byte_socket_handle.hpp:224
@ passive
Return addresses for binding to this machine.
Definition: byte_socket_handle.hpp:225

◆ family

The family of IP.

Enumerator
v4 

IP version 4.

v6 

IP version 6.

any 

Either v4 or v6.

70  {
71  unknown,
72  v4, //!< IP version 4
73  v6, //!< IP version 6
74  any //!< Either v4 or v6
75  };
@ any
Either v4 or v6.

Function Documentation

◆ resolve()

result<resolver_ptr> llfio_v2_xxx::ip::resolve ( string_view  name,
string_view  service,
family  _family = family::any,
deadline  d = {},
resolve_flag  flags = resolve_flag::none 
)
inlinenoexcept

Retrieve a list of potential address for a given name and service e.g. "www.google.com" and "https" optionally within a bounded deadline.

The object returned by this function can take many seconds to become ready as multiple network requests may need to be made. The deadline can be used to bound execution times – like in a few other places in LLFIO, this deadline does not cause timed out errors, rather it aborts any remaining name resolution after the deadline expires and returns whatever addresses have been resolved by the deadline.

This function has a future-like API as several major platforms provide native asynchronous name resolution (currently: Linux, Windows). On other platforms, std::async with getaddrinfo() is used as an emulation, and therefore deadline expiry means no partial list of addresses are returned.

If you become no longer interested in the results, simply reset or delete the pointer and the resolution will be aborted asynchronously.

Memory Allocations\n This is one of those very few APIs in LLFIO where dynamic memory allocation
is unbounded and uncontrollable thanks to how the platform APIs are implemented.