PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
profinet::IUdpSocket Class Referenceabstract

Abstract interface for IPv4 UDP datagram transport. More...

#include <IUdpSocket.h>

+ Inheritance diagram for profinet::IUdpSocket:
+ Collaboration diagram for profinet::IUdpSocket:

Public Member Functions

virtual ~IUdpSocket ()=default
 Virtual destructor for polymorphic use.
 
virtual UdpDatagram RecvFrom (std::size_t maxLen)=0
 Receive one UDP datagram and its source endpoint.
 
virtual void SendTo (const std::vector< std::uint8_t > &data, const UdpEndpoint &destination)=0
 Send a UDP datagram to a specific IPv4 endpoint.
 
virtual void SetTimeout (std::chrono::milliseconds timeout)=0
 Set the UDP receive timeout.
 

Detailed Description

Abstract interface for IPv4 UDP datagram transport.

Provides the minimal UDP functionality required by protocol components that receive datagrams and send responses to their source endpoint.

Implementations may use a connected UDP socket for peer-specific communication or a bound UDP socket for listener-style communication. The protocol layer does not depend on the underlying operating-system socket API.

Example:

class TestUdpSocket : public IUdpSocket
{
// Test implementation.
};
std::unique_ptr<IUdpSocket> socket =
std::make_unique<TestUdpSocket>();
Abstract interface for IPv4 UDP datagram transport.
Definition IUdpSocket.h:99
Note
Implementations must not retain caller-owned buffers after a method returns unless explicitly documented by the implementation.

Definition at line 98 of file IUdpSocket.h.

Constructor & Destructor Documentation

◆ ~IUdpSocket()

virtual profinet::IUdpSocket::~IUdpSocket ( )
virtualdefault

Virtual destructor for polymorphic use.

Member Function Documentation

◆ RecvFrom()

virtual UdpDatagram profinet::IUdpSocket::RecvFrom ( std::size_t  maxLen)
pure virtual

Receive one UDP datagram and its source endpoint.

Waits until a datagram is received or the configured receive timeout expires. A timeout is represented by an empty payload.

Parameters
maxLenMaximum number of payload bytes to receive.
Returns
The received datagram and its sender, or an empty datagram when the receive timeout expires.
Exceptions
SocketErrorWhen the underlying socket reports an error other than a receive timeout.

Implemented in profinet::UdpSocket.

◆ SendTo()

virtual void profinet::IUdpSocket::SendTo ( const std::vector< std::uint8_t > &  data,
const UdpEndpoint &  destination 
)
pure virtual

Send a UDP datagram to a specific IPv4 endpoint.

Parameters
dataDatagram payload to transmit.
destinationIPv4 address and UDP port of the destination.
Exceptions
SocketErrorWhen the endpoint is invalid or the datagram cannot be transmitted.

Implemented in profinet::UdpSocket.

◆ SetTimeout()

virtual void profinet::IUdpSocket::SetTimeout ( std::chrono::milliseconds  timeout)
pure virtual

Set the UDP receive timeout.

Parameters
timeoutMaximum time to wait for an incoming datagram.
Exceptions
SocketErrorWhen the underlying socket option cannot be changed.

Implemented in profinet::UdpSocket.


The documentation for this class was generated from the following file: