livox_mid360_core
C++ driver library for the Livox Mid-360 LiDAR
Loading...
Searching...
No Matches
transport.hpp File Reference

UDP transport layer: a thin, dependency-free wrapper over POSIX sockets. More...

#include <array>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <expected>
#include <optional>
#include <span>
#include <string>
#include <string_view>
#include <vector>
#include "livox/mid360/export.hpp"

Go to the source code of this file.

Classes

struct  livox::mid360::Endpoint
 IPv4 address + UDP port. Mid-360 is IPv4 only. More...
struct  livox::mid360::TransportError
 Error of a transport call: a category plus the errno it came from. More...
struct  livox::mid360::Datagram
 One received UDP datagram. More...
struct  livox::mid360::SocketOptions
 Options of UdpSocket::open(). More...
class  livox::mid360::UdpSocket
 Non-blocking IPv4 UDP socket. Move-only; closes the descriptor on destruction. More...
struct  livox::mid360::ReadyEvent
 One socket reported by Poller::wait(). More...
class  livox::mid360::Poller
 Waits for readability on a set of sockets. More...

Namespaces

namespace  livox
 Livox LiDAR drivers.
namespace  livox::mid360
 The livox_mid360_core library: everything declared by the public headers.

Enumerations

enum class  livox::mid360::TransportErrorCode : std::uint8_t {
  livox::mid360::kSocketCreate , livox::mid360::kBind , livox::mid360::kSetOption , livox::mid360::kAddressInUse ,
  livox::mid360::kNetworkUnreachable , livox::mid360::kSendFailed , livox::mid360::kMessageTooLong , livox::mid360::kWouldBlock ,
  livox::mid360::kTimeout , livox::mid360::kInterrupted , livox::mid360::kClosed , livox::mid360::kInvalidArgument ,
  livox::mid360::kOther
}
 Category of a TransportError. More...

Functions

std::optional< Endpoint > livox::mid360::parse_endpoint (std::string_view text)
 Parse "a.b.c.d" (port = 0) or "a.b.c.d:port". Returns nullopt on malformed input.
std::string livox::mid360::to_string (const Endpoint &ep)
 Format as "a.b.c.d:port".
std::string livox::mid360::ip_to_string (const std::array< std::uint8_t, 4 > &ip)
 Format only the address part, "a.b.c.d".
std::string_view livox::mid360::to_string (TransportErrorCode code)
 Short snake_case name, e.g. "would_block".
std::string livox::mid360::to_string (const TransportError &err)
 Human readable "code (strerror)" text.

Variables

constexpr std::size_t livox::mid360::kMaxDatagramSize = 1500
 Maximum datagram size worth allocating for: Ethernet MTU.

Detailed Description

UDP transport layer: a thin, dependency-free wrapper over POSIX sockets.

Design (see issue #2):

  • Non-blocking sockets multiplexed with a Poller (poll(2) today, epoll-ready API).
  • Caller-owned buffers: recv_batch() fills spans the caller provides, mirroring the protocol layer's non-owning views.
  • Errors are std::expected<T, TransportError>; no exceptions.
  • Thread creation is the responsibility of the upper layers.
  • Ubuntu 24.04 is the target; macOS keeps building for development via fallbacks.