|
| | UdpSocket () |
| | Opens a new UDP socket.
|
| |
|
| ~UdpSocket () noexcept |
| | Closes the socket if it is still open.
|
| |
|
| UdpSocket (const UdpSocket &)=delete |
| |
|
UdpSocket & | operator= (const UdpSocket &)=delete |
| |
| | UdpSocket (UdpSocket &&other) noexcept |
| | Move constructor — transfers ownership of the socket.
|
| |
| UdpSocket & | operator= (UdpSocket &&other) noexcept |
| | Move-assignment operator — transfers ownership of the socket.
|
| |
| Result< void > | bind (const Address &addr) noexcept |
| | Binds the socket to a local address.
|
| |
| Result< size_t > | send_to (const void *data, size_t len, const Address &dest) noexcept |
| | Sends a datagram to a specific destination.
|
| |
| Result< size_t > | recv_from (void *buf, size_t len, Address *src=nullptr, std::chrono::nanoseconds timeout=wait_forever) noexcept |
| | Receives a datagram and the sender's address.
|
| |
| void | close () |
| | Closes the UDP socket.
|
| |
| bool | is_open () const |
| | Returns true if the socket is open.
|
| |
| ove_socket_t | handle () const |
| | Returns the raw oveRTOS socket handle.
|
| |
RAII wrapper around an oveRTOS UDP (datagram) socket.
A new socket is opened on construction and closed on destruction.
- Note
- Non-copyable. Move-only when heap allocation is enabled.
| void ove::UdpSocket::close |
( |
| ) |
|
|
inline |
Closes the UDP socket.
Idempotent. Safe to call on an already-closed socket — the call is silently a no-op in that case. The destructor calls this as part of cleanup, so explicit close() is only needed when you want to release the underlying file descriptor before the UdpSocket goes out of scope.
Effect on pending I/O. Another thread blocked on recv_from (or any send_to in progress) against the same handle will unblock with a backend-specific error code — typically OVE_ERR_NET_CLOSED. Further send_to / recv_from calls on this wrapper fail fast.
Thread-safety. Not safe to call concurrently with another close() on the same handle, nor concurrently with send_to or recv_from on a thread that does not expect the handle to disappear. Coordinate teardown via the usual signal-then-close pattern.