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.

234  {
235  none = 0, //!< No flags
236  passive = (1U << 0U), //!< Return addresses for binding to this machine.
237  blocking = (1U << 1U) //!< Execute address resolution synchronously.
238  } QUICKCPPLIB_BITFIELD_END(resolve_flag)
@ blocking
Execute address resolution synchronously.
Definition: byte_socket_handle.hpp:237
@ none
No flags.
Definition: byte_socket_handle.hpp:235
@ passive
Return addresses for binding to this machine.
Definition: byte_socket_handle.hpp:236

◆ family

The family of IP.

Enumerator
v4 

IP version 4.

v6 

IP version 6.

any 

Either v4 or v6.

79  {
80  unknown,
81  v4, //!< IP version 4
82  v6, //!< IP version 6
83  any //!< Either v4 or v6
84  };
@ 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.

Warning
This is deprecated and scheduled for removal in 2025.

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.