UDP handle. More...
#include "handle-udp.hpp"
Classes | |
| struct | io_info |
Supplemental data passed as the last argument to io::on_read_t callback function called by recv_start(). More... | |
Public Types | |
| using | uv_t = ::uv_udp_t |
Public Types inherited from uv::io | |
| using | uv_t = void |
| using | on_read_t = std::function< void(io _handle, ssize_t _nread, buffer _buffer, int64_t _offset, void *_info) > |
The function type of the callback called by read_start() when data was read from an I/O endpoint. More... | |
Public Types inherited from uv::handle | |
| using | uv_t = ::uv_handle_t |
| using | on_destroy_t = std::function< void(void *_data) > |
| The function type of the callback called when the handle has been closed and about to be destroyed. More... | |
Public Member Functions | |
| udp (const udp &)=default | |
| udp & | operator= (const udp &)=default |
| udp (udp &&) noexcept=default | |
| udp & | operator= (udp &&) noexcept=default |
| udp (uv::loop &_loop, unsigned int _flags=AF_UNSPEC) | |
| udp (uv::loop &_loop, ::uv_os_sock_t _socket) | |
| ::uv_os_sock_t | socket () const noexcept |
Get the platform dependent socket descriptor. The alias for handle::fileno(). | |
| std::size_t | send_queue_size () const noexcept |
| Number of bytes queued for sending. This field strictly shows how much information is currently queued. | |
| std::size_t | send_queue_count () const noexcept |
| Number of send requests currently in the queue awaiting to be processed. | |
| template<typename _T_ , typename = std::enable_if_t< is_one_of< _T_, ::sockaddr, ::sockaddr_in, ::sockaddr_in6, ::sockaddr_storage >::value >> | |
| int | bind (const _T_ &_sockaddr, unsigned int _flags=0) noexcept |
| template<typename _T_ , typename = std::enable_if_t< is_one_of< _T_, ::sockaddr_in, ::sockaddr_in6, ::sockaddr_storage >::value >> | |
| bool | getsockname (_T_ &_sockaddr) const noexcept |
| Get the local address and port which this handle is bound to. More... | |
| int | set_ttl (int _value) noexcept |
| Set the time to live value. More... | |
| int | recv_start (const on_buffer_alloc_t &_alloc_cb, const on_read_t &_recv_cb, std::size_t _size=0) const |
Alias for io::read_start(). | |
| int | recv_start (std::size_t _size=0) const |
| Idem. | |
| int | recv_stop () const |
Alias for io::read_stop(). | |
| unsigned int | send_buffer_size () const noexcept |
| Get the size of the send buffer that the operating system uses for the socket. More... | |
| void | send_buffer_size (unsigned int _value) noexcept |
| Set the size of the send buffer that the operating system uses for the socket. More... | |
| unsigned int | recv_buffer_size () const noexcept |
| Get the size of the receive buffer that the operating system uses for the socket. More... | |
| void | recv_buffer_size (unsigned int _value) noexcept |
| Set the size of the receive buffer that the operating system uses for the socket. More... | |
| operator const uv_t * () const noexcept | |
| operator uv_t * () noexcept | |
UDP multicast/broadcast features: | |
| int | set_multicast_membership (const char *_multicast_addr, const char *_interface_addr, ::uv_membership _membership) noexcept |
| Set membership for a multicast address. More... | |
| int | set_multicast_loop (bool _enable) noexcept |
| Set IP multicast loop flag. Makes multicast packets loop back to local sockets. More... | |
| int | set_multicast_ttl (int _value) noexcept |
| Set the multicast TTL value. More... | |
| int | set_multicast_interface (const char *_interface_addr) noexcept |
| Set the multicast interface to send or receive data on. More... | |
| int | set_broadcast (bool _enable) noexcept |
| Set broadcast on or off. More... | |
Public Member Functions inherited from uv::io | |
| io (const io &)=default | |
| io & | operator= (const io &)=default |
| io (io &&) noexcept=default | |
| io & | operator= (io &&) noexcept=default |
| std::size_t | write_queue_size () const noexcept |
| The amount of queued bytes waiting to be written/sent to the I/O endpoint. More... | |
| on_buffer_alloc_t & | on_alloc () const noexcept |
| Set the input buffer allocation callback. | |
| on_read_t & | on_read () const noexcept |
| Set the read callback function. | |
| int | read_start (std::size_t _size=0, int64_t _offset=-1) const |
| Start reading incoming data from the I/O endpoint. More... | |
| int | read_start (const on_buffer_alloc_t &_alloc_cb, const on_read_t &_read_cb, std::size_t _size=0, int64_t _offset=-1) const |
Start reading incoming data from the I/O endpoint with provided input buffer allocation callback (_alloc_cb) and read callback function (_read_cb). More... | |
| int | read_stop () const |
| Stop reading data from the I/O endpoint. More... | |
| int | read_pause (bool _trigger_condition) const |
| Pause reading data from the I/O endpoint. More... | |
| int | read_resume (bool _trigger_condition) |
| Resume reading data from the I/O endpoint after having been paused. More... | |
| operator const uv_t * () const noexcept | |
| operator uv_t * () noexcept | |
Public Member Functions inherited from uv::handle | |
| handle (const handle &_that) | |
| handle & | operator= (const handle &_that) |
| handle (handle &&_that) noexcept | |
| handle & | operator= (handle &&_that) noexcept |
| void | swap (handle &_that) noexcept |
| std::uintptr_t | id () const noexcept |
| The unique ID of the instance managed by this handle variable or 0 if the handle is void. | |
| long | nrefs () const noexcept |
| The current number of existing references to the same object as this handle variable refers to. | |
| int | uv_status () const noexcept |
| The status value returned by the last executed libuv API function on this handle. | |
| on_destroy_t & | on_destroy () const noexcept |
| ::uv_handle_type | type () const noexcept |
| The tag indicating the libuv type of the handle. | |
| const char * | type_name () const noexcept |
| A string containing the name of the handle type. | |
| uv::loop | loop () const noexcept |
| The libuv loop where the handle is running on. More... | |
| void *& | data () const noexcept |
| The pointer to the user-defined arbitrary data. libuv and uvcc does not use this field. | |
| int | is_active () const noexcept |
| Check if the handle is active. More... | |
| int | is_closing () const noexcept |
| Check if the handle is closing or closed. More... | |
| ::uv_os_fd_t | fileno () const noexcept |
| Get the platform dependent handle/file descriptor. More... | |
| operator const uv_t * () const noexcept | |
| operator uv_t * () noexcept | |
| operator bool () const noexcept | |
Equivalent to (id() and uv_status() >= 0). | |
| void | attached (bool _state) const noexcept |
| bool | attached () const noexcept |
Additional Inherited Members | |
Static Public Member Functions inherited from uv::io | |
| static io | guess_handle (uv::loop &, ::uv_file) |
Create an io handle object which actual type is derived from an existing file descriptor. More... | |
UDP handle.
uv_udp_t — UDP handle. Definition at line 23 of file handle-udp.hpp.
|
inline |
Create a UDP socket with the specified flags.
AF_UNSPEC flag no socket is actually created on the system. uv_udp_init_ex().Definition at line 95 of file handle-udp.hpp.
|
inline |
Create a handle object from an existing native platform depended datagram socket descriptor.
uv_udp_open(), uv_udp_init(). Definition at line 107 of file handle-udp.hpp.
|
inlinenoexcept |
Set membership for a multicast address.
uv_udp_set_membership(), uv_membership. Definition at line 137 of file handle-udp.hpp.
|
inlinenoexcept |
Set IP multicast loop flag. Makes multicast packets loop back to local sockets.
uv_udp_set_multicast_loop(). Definition at line 146 of file handle-udp.hpp.
|
inlinenoexcept |
Set the multicast TTL value.
uv_udp_set_multicast_ttl(). Definition at line 150 of file handle-udp.hpp.
|
inlinenoexcept |
Set the multicast interface to send or receive data on.
uv_udp_set_multicast_interface(). Definition at line 154 of file handle-udp.hpp.
|
inlinenoexcept |
Set broadcast on or off.
uv_udp_set_broadcast(). Definition at line 158 of file handle-udp.hpp.
|
inlinenoexcept |
Bind the handle to an address and port.
uv_udp_bind(), uv_udp_flags. Definition at line 169 of file handle-udp.hpp.
|
inlinenoexcept |
Get the local address and port which this handle is bound to.
true if the operation has completed successfully (can be checked with uv_status()) and the size of the passed argument (i.e. sizeof(_T_)) is enough to hold the returned socket address structure. uv_udp_getsockname(). Definition at line 179 of file handle-udp.hpp.
|
inlinenoexcept |
Set the time to live value.
uv_udp_set_ttl(). Definition at line 190 of file handle-udp.hpp.
|
inlinenoexcept |
Get the size of the send buffer that the operating system uses for the socket.
uv_send_buffer_size(). Definition at line 203 of file handle-udp.hpp.
|
inlinenoexcept |
Set the size of the send buffer that the operating system uses for the socket.
uv_send_buffer_size(). Definition at line 211 of file handle-udp.hpp.
|
inlinenoexcept |
Get the size of the receive buffer that the operating system uses for the socket.
uv_recv_buffer_size(). Definition at line 215 of file handle-udp.hpp.
|
inlinenoexcept |
Set the size of the receive buffer that the operating system uses for the socket.
uv_recv_buffer_size(). Definition at line 223 of file handle-udp.hpp.