|
livox_mid360_core
C++ driver library for the Livox Mid-360 LiDAR
|
Non-blocking IPv4 UDP socket. Move-only; closes the descriptor on destruction. More...
#include <livox/mid360/transport.hpp>
Public Member Functions | |
| UdpSocket (UdpSocket &&other) noexcept | |
| Takes over the descriptor; other is left closed. | |
| UdpSocket & | operator= (UdpSocket &&other) noexcept |
| Closes the current descriptor and takes over the one of other. | |
| UdpSocket (const UdpSocket &)=delete | |
| UdpSocket & | operator= (const UdpSocket &)=delete |
| bool | is_open () const noexcept |
| True while the socket holds a descriptor. | |
| int | native_handle () const noexcept |
| Raw descriptor (for Poller and tests). -1 when closed. | |
| Endpoint | local_endpoint () const noexcept |
| Address actually bound (port resolved when 0 was requested). | |
| std::expected< std::size_t, TransportError > | recv_buffer_bytes () const |
| Effective SO_RCVBUF as reported by the kernel. | |
| std::expected< std::size_t, TransportError > | send_to (std::span< const std::byte > data, const Endpoint &to) const |
| Send one datagram. Returns bytes sent (always data.size() for UDP on success). | |
| std::expected< std::size_t, TransportError > | recv_batch (std::span< Datagram > out) const |
| Receive up to out.size() datagrams without blocking. | |
| std::expected< Datagram, TransportError > | recv_one (std::span< std::byte > buffer) const |
| Convenience: receive a single datagram into buffer. | |
| void | close () noexcept |
| Close the descriptor. Safe to call on a closed socket. | |
Static Public Member Functions | |
| static std::expected< UdpSocket, TransportError > | open (Endpoint bind_to, const SocketOptions &options={}) |
| Create a non-blocking socket and bind it to bind_to (port 0 = ephemeral). | |
Non-blocking IPv4 UDP socket. Move-only; closes the descriptor on destruction.
|
staticnodiscard |
Create a non-blocking socket and bind it to bind_to (port 0 = ephemeral).
Setting the reserved multicast_group or bind_to_device fails with kInvalidArgument.
|
nodiscard |
Receive up to out.size() datagrams without blocking.
Each out[i].data must point to a caller-owned buffer on entry; on return it is trimmed to the received size and from / recv_time_ns are filled. Returns the number of datagrams received, or kWouldBlock when nothing is pending.