uvcc
libuv C++ bindings
uv::udp_send Class Reference

UDP send request type. More...

#include "request-udp.hpp"

Inheritance diagram for uv::udp_send:
uv::request

Public Types

using uv_t = ::uv_udp_send_t
 
using on_request_t = std::function< void(udp_send _request, buffer _buffer) >
 The function type of the callback called after data was sent. More...
 
- Public Types inherited from uv::request
using uv_t = ::uv_req_t
 
using on_destroy_t = std::function< void(void *_data) >
 The function type of the callback called when the request object is about to be destroyed.
 

Public Member Functions

 udp_send (const udp_send &)=default
 
udp_sendoperator= (const udp_send &)=default
 
 udp_send (udp_send &&) noexcept=default
 
udp_sendoperator= (udp_send &&) noexcept=default
 
on_request_ton_request () const noexcept
 
udp handle () const noexcept
 The UDP handle where this send request has been taking place.
 
template<typename _T_ , typename = std::enable_if_t< is_one_of< _T_, ::sockaddr_in, ::sockaddr_in6, ::sockaddr_storage >::value >>
bool getpeername (_T_ &_sockaddr) const noexcept
 Get the address of the remote peer which this request has sent data to. More...
 
template<typename _T_ , typename = std::enable_if_t< is_one_of< _T_, ::sockaddr, ::sockaddr_in, ::sockaddr_in6, ::sockaddr_storage >::value >>
int run (udp &_udp, const buffer &_buf, const _T_ &_sockaddr)
 Run the request. More...
 
template<typename _T_ , typename = std::enable_if_t< is_one_of< _T_, ::sockaddr, ::sockaddr_in, ::sockaddr_in6, ::sockaddr_storage >::value >>
int try_send (udp &_udp, const buffer &_buf, const _T_ &_sockaddr)
 
 operator const uv_t * () const noexcept
 
 operator uv_t * () noexcept
 
- Public Member Functions inherited from uv::request
 request (const request &_that)
 
requestoperator= (const request &_that)
 
 request (request &&_that) noexcept
 
requestoperator= (request &&_that) noexcept
 
void swap (request &_that) noexcept
 
std::uintptr_t id () const noexcept
 
long nrefs () const noexcept
 The current number of existing references to the same object as this request variable refers to.
 
int uv_status () const noexcept
 The status value returned by the last executed libuv API function on this request.
 
on_destroy_ton_destroy () const noexcept
 
::uv_req_type type () const noexcept
 The tag indicating a libuv type of the request. More...
 
const char * type_name () const noexcept
 A string containing the name of the request type.
 
void *const & data () const noexcept
 The pointer to the user-defined arbitrary data. libuv and uvcc does not use this field.
 
void *& data () noexcept
 
int cancel () noexcept
 Cancel a pending request. More...
 
 operator const uv_t * () const noexcept
 
 operator uv_t * () noexcept
 
 operator bool () const noexcept
 Equivalent to (uv_status() >= 0).
 

Detailed Description

UDP send request type.

See also
libuv API documentation: uv_udp_t — UDP handle.

Definition at line 24 of file request-udp.hpp.

Member Typedef Documentation

◆ on_request_t

using uv::udp_send::on_request_t = std::function< void(udp_send _request, buffer _buffer) >

The function type of the callback called after data was sent.

See also
libuv API documentation: uv_udp_send_cb.

Definition at line 35 of file request-udp.hpp.

Member Function Documentation

◆ getpeername()

template<typename _T_ , typename = std::enable_if_t< is_one_of< _T_, ::sockaddr_in, ::sockaddr_in6, ::sockaddr_storage >::value >>
bool uv::udp_send::getpeername ( _T_ &  _sockaddr) const
inlinenoexcept

Get the address of the remote peer which this request has sent data to.

Returns
true if sizeof(_T_) is enough to hold the returned socket address structure.

Definition at line 83 of file request-udp.hpp.

◆ run()

template<typename _T_ , typename = std::enable_if_t< is_one_of< _T_, ::sockaddr, ::sockaddr_in, ::sockaddr_in6, ::sockaddr_storage >::value >>
int uv::udp_send::run ( udp _udp,
const buffer _buf,
const _T_ &  _sockaddr 
)
inline

Run the request.

Send data over the UDP socket. If the socket has not previously been bound with udp::bind() it will be bound to 0.0.0.0 (the “all interfaces” IPv4 address) and a random port number.

See also
libuv API documentation: uv_udp_send().

Definition at line 102 of file request-udp.hpp.

◆ try_send()

template<typename _T_ , typename = std::enable_if_t< is_one_of< _T_, ::sockaddr, ::sockaddr_in, ::sockaddr_in6, ::sockaddr_storage >::value >>
int uv::udp_send::try_send ( udp _udp,
const buffer _buf,
const _T_ &  _sockaddr 
)
inline

The wrapper for a corresponding libuv function.

Note
It tries to execute and complete immediately and does not call the request callback.
See also
libuv API documentation: uv_udp_try_send().

Definition at line 141 of file request-udp.hpp.


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