PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
IUdpSocket.h
Go to the documentation of this file.
1
19#pragma once
20
21// #ifdef _WIN32
22// #include <winsock2.h>
23// #else
24// #include <netinet/in.h>
25// #endif
26
27#include <chrono>
28#include <cstddef>
29#include <cstdint>
30#include <string>
31#include <vector>
32
33namespace profinet
34{
35
42{
44 std::string address;
45
47 std::uint16_t port = 0;
48
52 bool operator==(const UdpEndpoint& other) const = default;
53};
54
65{
67 std::vector<std::uint8_t> data;
68
71};
72
99{
100 public:
102 virtual ~IUdpSocket() = default;
103
117 [[nodiscard]] virtual UdpDatagram RecvFrom(std::size_t maxLen) = 0;
118
125 virtual void SendTo(const std::vector<std::uint8_t>& data, const UdpEndpoint& destination) = 0;
126
132 virtual void SetTimeout(std::chrono::milliseconds timeout) = 0;
133};
134
135} // namespace profinet
Abstract interface for IPv4 UDP datagram transport.
Definition IUdpSocket.h:99
virtual void SetTimeout(std::chrono::milliseconds timeout)=0
Set the UDP receive timeout.
virtual void SendTo(const std::vector< std::uint8_t > &data, const UdpEndpoint &destination)=0
Send a UDP datagram to a specific IPv4 endpoint.
virtual ~IUdpSocket()=default
Virtual destructor for polymorphic use.
virtual UdpDatagram RecvFrom(std::size_t maxLen)=0
Receive one UDP datagram and its source endpoint.
A UDP datagram together with the IPv4 address of its sender.
Definition IUdpSocket.h:65
std::vector< std::uint8_t > data
Datagram payload.
Definition IUdpSocket.h:67
UdpEndpoint source
IPv4 address and UDP port of the datagram sender.
Definition IUdpSocket.h:70
Portable IPv4 UDP endpoint.
Definition IUdpSocket.h:42
std::string address
Numeric IPv4 address in dotted-decimal notation.
Definition IUdpSocket.h:44
bool operator==(const UdpEndpoint &other) const =default
Compare two UDP endpoints.
std::uint16_t port
UDP port in host byte order.
Definition IUdpSocket.h:47