|
PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
|
A connected UDP socket with a timeout. More...
#include <util.h>
Collaboration diagram for profinet::UdpSocket:Public Member Functions | |
| UdpSocket (const std::string &host, std::uint16_t port, std::chrono::duration< double > timeout=std::chrono::duration< double >(defaultTimeout)) | |
| Resolve a host and connect a UDP socket to it. | |
| ~UdpSocket () | |
| Close the underlying socket. | |
| UdpSocket (const UdpSocket &)=delete | |
| Not copyable (owns a socket file descriptor). | |
| UdpSocket & | operator= (const UdpSocket &)=delete |
| Not copyable (owns a socket file descriptor). | |
| UdpSocket (UdpSocket &&other) noexcept | |
| Move-construct, transferring ownership of the underlying socket. | |
| UdpSocket & | operator= (UdpSocket &&other) noexcept |
| Move-assign, transferring ownership of the underlying socket. | |
| void | Send (const std::vector< std::uint8_t > &data) const |
| Send a UDP datagram to the connected peer. | |
| std::vector< std::uint8_t > | Recv (std::size_t maxLen=defaultReceiveBufferSize) const |
| Receive a UDP datagram from the connected peer. | |
| int | Fd () const |
| The underlying file descriptor. | |
Static Public Attributes | |
| static constexpr double | defaultTimeout = 5.0 |
| Default Timeout. | |
| static constexpr int | defaultReceiveBufferSize = 65536 |
| Default receive buffer size. | |
Private Attributes | |
| int | fd = -1 |
| Underlying socket file descriptor, or -1 if closed/moved-from. | |
A connected UDP socket with a timeout.
Works cross-platform; no raw-socket privileges required.
| profinet::UdpSocket::UdpSocket | ( | const std::string & | host, |
| std::uint16_t | port, | ||
| std::chrono::duration< double > | timeout = std::chrono::duration<double>(defaultTimeout) |
||
| ) |
| profinet::UdpSocket::~UdpSocket | ( | ) |
|
delete |
Not copyable (owns a socket file descriptor).
|
noexcept |
|
inline |
Not copyable (owns a socket file descriptor).
| std::vector< std::uint8_t > profinet::UdpSocket::Recv | ( | std::size_t | maxLen = defaultReceiveBufferSize | ) | const |
| void profinet::UdpSocket::Send | ( | const std::vector< std::uint8_t > & | data | ) | const |
|
staticconstexpr |
|
staticconstexpr |
|
private |
Underlying socket file descriptor, or -1 if closed/moved-from.
Definition at line 305 of file util.h.
Referenced by UdpSocket(), ~UdpSocket(), Fd(), Recv(), and Send().