IPv4 UDP socket bound for the sonar's multicast or unicast stream.
More...
#include <waterlinkedsonar/udp/socket.hpp>
|
| | UdpSocket (const UdpSocketConfig &config) |
| | Binds the socket and, in MULTICAST mode, joins the group with SO_REUSEADDR set so that several receivers can share the port.
|
| |
|
| ~UdpSocket () |
| | Closes the socket.
|
| |
|
| UdpSocket (UdpSocket &&other) noexcept |
| | Takes over the socket of other, which may only be destroyed or assigned to afterwards.
|
| |
|
UdpSocket & | operator= (UdpSocket &&other) noexcept |
| | Closes this socket and takes over the socket of other.
|
| |
|
| UdpSocket (const UdpSocket &)=delete |
| |
|
UdpSocket & | operator= (const UdpSocket &)=delete |
| |
| std::optional< Datagram > | receive (Span< std::uint8_t > buffer, std::chrono::milliseconds timeout) |
| | Waits up to timeout for a datagram and copies it into buffer, truncating it to the buffer size.
|
| |
| std::uint16_t | local_port () const |
| | Port the socket is bound to; useful when the configured port was 0.
|
| |
IPv4 UDP socket bound for the sonar's multicast or unicast stream.
◆ UdpSocket()
Binds the socket and, in MULTICAST mode, joins the group with SO_REUSEADDR set so that several receivers can share the port.
- Exceptions
-
| std::system_error | on failure, including EADDRINUSE when another socket holds the port in UNICAST mode. |
◆ local_port()
| std::uint16_t waterlinked::sonar::UdpSocket::local_port |
( |
| ) |
const |
Port the socket is bound to; useful when the configured port was 0.
- Exceptions
-
| std::system_error | if the socket cannot be queried. |
◆ receive()
| std::optional< Datagram > waterlinked::sonar::UdpSocket::receive |
( |
Span< std::uint8_t > |
buffer, |
|
|
std::chrono::milliseconds |
timeout |
|
) |
| |
Waits up to timeout for a datagram and copies it into buffer, truncating it to the buffer size.
- Returns
- The datagram, or std::nullopt on timeout.
- Exceptions
-
| std::system_error | on a socket error. |
The documentation for this class was generated from the following file: