Group Network

Modules > Network

More...

Classes

Type Name
class coro::io_recv
Awaitable type to perform recv I/O request.
class coro::io_recv_from
Awaitable type to perform recvfrom I/O request.
class coro::io_send
Awaitable type to perform send I/O request.
class coro::io_send_to
Awaitable type to perform sendto I/O request.
class coro::io_work_t
A struct to describe "1 I/O request" to system API. When I/O request is submitted, an I/O task becomes 1 coroutine handle.

Public Types

Type Name
typedef gsl::span< std::byte > coro::io_buffer_t
This is simply a view to storage. Be aware that it doesn't have ownership.

Public Functions

Type Name
uint32_t coro::get_address (const addrinfo & hint, gsl::czstring<> host, gsl::czstring<> serv, gsl::span< sockaddr_in > output) noexcept
Thin wrapper of getaddrinfo for IPv4.
uint32_t coro::get_address (const addrinfo & hint, gsl::czstring<> host, gsl::czstring<> serv, gsl::span< sockaddr_in6 > output) noexcept
Thin wrapper of getaddrinfo for IPv6.
uint32_t coro::get_name (const sockaddr_in & addr, gsl::zstring< NI_MAXHOST > name, gsl::zstring< NI_MAXSERV > serv, int32_t flags=NI_NUMERICHOST
uint32_t coro::get_name (const sockaddr_in6 & addr, gsl::zstring< NI_MAXHOST > name, gsl::zstring< NI_MAXSERV > serv, int32_t flags=NI_NUMERICHOST
void coro::poll_net_tasks (uint64_t nano) noexcept
Poll internal I/O works and invoke user callback.
auto coro::recv_from (uint64_t sd, sockaddr_in & remote, io_buffer_t buf, io_work_t & work) noexcept
Constructs io_recv_from awaitable with the given parameters.
auto coro::recv_from (uint64_t sd, sockaddr_in6 & remote, io_buffer_t buf, io_work_t & work) noexcept
Constructs io_recv_from awaitable with the given parameters.
auto coro::recv_stream (uint64_t sd, io_buffer_t buf, uint32_t flag, io_work_t & work) noexcept
Constructs io_recv awaitable with the given parameters.
auto coro::send_stream (uint64_t sd, io_buffer_t buf, uint32_t flag, io_work_t & work) noexcept
Constructs io_send awaitable with the given parameters.
auto coro::send_to (uint64_t sd, const sockaddr_in & remote, io_buffer_t buf, io_work_t & work) noexcept
Constructs io_send_to awaitable with the given parameters.
auto coro::send_to (uint64_t sd, const sockaddr_in6 & remote, io_buffer_t buf, io_work_t & work) noexcept
Constructs io_send_to awaitable with the given parameters.

Detailed Description

Helper types to apply co_await for socket operations + Name resolution utilities

Public Types Documentation

typedef io_buffer_t

using coro::io_buffer_t = typedef gsl::span<std::byte>;

Public Functions Documentation

function get_address

uint32_t coro::get_address (
    const addrinfo & hint,
    gsl::czstring<> host,
    gsl::czstring<> serv,
    gsl::span< sockaddr_in > output
) noexcept

Parameters:

  • hint
  • host
  • serv
  • output

Returns:

uint32_t Error code from the getaddrinfo that can be the argument of gai_strerror

See also: getaddrinfo

See also: gai_strerror

function get_address

uint32_t coro::get_address (
    const addrinfo & hint,
    gsl::czstring<> host,
    gsl::czstring<> serv,
    gsl::span< sockaddr_in6 > output
) noexcept

Parameters:

  • hint
  • host
  • serv
  • output

Returns:

uint32_t Error code from the getaddrinfo that can be the argument of gai_strerror

See also: getaddrinfo

See also: gai_strerror

function get_name

uint32_t coro::get_name (
    const sockaddr_in & addr,
    gsl::zstring< NI_MAXHOST > name,
    gsl::zstring< NI_MAXSERV > serv,
    int32_t flags=NI_NUMERICHOST|NI_NUMERICSERV
) noexcept

Parameters:

  • addr
  • name
  • serv can be nullptr
  • flags

Returns:

uint32_t EAI_AGAIN ...

See also: getnameinfo

function get_name

uint32_t coro::get_name (
    const sockaddr_in6 & addr,
    gsl::zstring< NI_MAXHOST > name,
    gsl::zstring< NI_MAXSERV > serv,
    int32_t flags=NI_NUMERICHOST|NI_NUMERICSERV
) noexcept

Parameters:

  • addr
  • name
  • serv can be nullptr
  • flags

Returns:

uint32_t EAI_AGAIN ...

See also: getnameinfo

function poll_net_tasks

void coro::poll_net_tasks (
    uint64_t nano
) noexcept

Parameters:

  • nano timeout in nanoseconds

Exception:

  • std::system_error

function recv_from

auto coro::recv_from (
    uint64_t sd,
    sockaddr_in & remote,
    io_buffer_t buf,
    io_work_t & work
) noexcept

Parameters:

  • sd
  • remote
  • buf
  • work

Returns:

io_recv_from&

function recv_from

auto coro::recv_from (
    uint64_t sd,
    sockaddr_in6 & remote,
    io_buffer_t buf,
    io_work_t & work
) noexcept

Parameters:

  • sd
  • remote
  • buf
  • work

Returns:

io_recv_from&

function recv_stream

auto coro::recv_stream (
    uint64_t sd,
    io_buffer_t buf,
    uint32_t flag,
    io_work_t & work
) noexcept

Parameters:

  • sd
  • buf
  • flag
  • work

Returns:

io_recv&

function send_stream

auto coro::send_stream (
    uint64_t sd,
    io_buffer_t buf,
    uint32_t flag,
    io_work_t & work
) noexcept

Parameters:

  • sd
  • buf
  • flag
  • work

Returns:

io_send&

function send_to

auto coro::send_to (
    uint64_t sd,
    const sockaddr_in & remote,
    io_buffer_t buf,
    io_work_t & work
) noexcept

Parameters:

  • sd
  • remote
  • buf
  • work

Returns:

io_send_to&

function send_to

auto coro::send_to (
    uint64_t sd,
    const sockaddr_in6 & remote,
    io_buffer_t buf,
    io_work_t & work
) noexcept

Parameters:

  • sd
  • remote
  • buf
  • work

Returns:

io_send_to&