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

Synchronous UDP transport used by PROFINET DCE/RPC. More...

#include <rpcTransport.h>

+ Inheritance diagram for profinet::rpc::RpcTransport:
+ Collaboration diagram for profinet::rpc::RpcTransport:

Public Member Functions

 RpcTransport (asio::io_context &ioContext)
 Create a transport using the supplied Asio execution context.
 
void Open (const std::string &address, std::uint16_t port, bool isListener=false)
 Open the UDP socket and configure the remote endpoint.
 
Bytes Receive (std::chrono::milliseconds timeout, asio::ip::udp::endpoint &remoteEndpoint)
 Wait for an incoming UDP datagram and capture the sender's endpoint.
 
void SendTo (const Bytes &data, const asio::ip::udp::endpoint &targetEndpoint)
 Send a UDP datagram to a specific remote endpoint.
 
Bytes SendReceive (const Bytes &data, std::chrono::milliseconds timeout) override
 Send a UDP datagram and wait for one response.
 
void Send (const Bytes &data) override
 Send a UDP datagram without waiting for a response.
 
void Close () noexcept
 Close the UDP socket.
 
bool IsOpen () const noexcept
 Check whether the socket is open.
 
- Public Member Functions inherited from profinet::rpc::IRpcTransport
virtual ~IRpcTransport ()=default
 

Private Attributes

asio::io_context & ioContext
 
asio::ip::udp::socket socket
 
asio::ip::udp::endpoint endpoint
 

Detailed Description

Synchronous UDP transport used by PROFINET DCE/RPC.

Definition at line 17 of file rpcTransport.h.

Constructor & Destructor Documentation

◆ RpcTransport()

profinet::rpc::RpcTransport::RpcTransport ( asio::io_context &  ioContext)
explicit

Create a transport using the supplied Asio execution context.

Parameters
ioContextAsio execution context.

Definition at line 22 of file rpcTransport.cpp.

Member Function Documentation

◆ Close()

void profinet::rpc::RpcTransport::Close ( )
noexcept

Close the UDP socket.

Definition at line 335 of file rpcTransport.cpp.

References socket.

◆ IsOpen()

bool profinet::rpc::RpcTransport::IsOpen ( ) const
noexcept

Check whether the socket is open.

Returns
True when the UDP socket is open.

Definition at line 346 of file rpcTransport.cpp.

References socket.

◆ Open()

void profinet::rpc::RpcTransport::Open ( const std::string &  address,
std::uint16_t  port,
bool  isListener = false 
)

Open the UDP socket and configure the remote endpoint.

Parameters
addressRemote IPv4 address.
portRemote UDP port.
isListener...

Definition at line 27 of file rpcTransport.cpp.

References endpoint, and socket.

Referenced by profinet::rpc::EpmLookup().

+ Here is the caller graph for this function:

◆ Receive()

Bytes profinet::rpc::RpcTransport::Receive ( std::chrono::milliseconds  timeout,
asio::ip::udp::endpoint &  remoteEndpoint 
)

Wait for an incoming UDP datagram and capture the sender's endpoint.

Parameters
timeoutMaximum wait time.
[out]remoteEndpointReceives the endpoint details of the sender.
Returns
Received datagram.

Definition at line 105 of file rpcTransport.cpp.

References ioContext, profinet::RECEIVE_BUFFER_LENGTH, and socket.

◆ Send()

void profinet::rpc::RpcTransport::Send ( const Bytes data)
overridevirtual

Send a UDP datagram without waiting for a response.

Parameters
dataDatagram to send.

Implements profinet::rpc::IRpcTransport.

Definition at line 310 of file rpcTransport.cpp.

References endpoint, and socket.

◆ SendReceive()

Bytes profinet::rpc::RpcTransport::SendReceive ( const Bytes data,
std::chrono::milliseconds  timeout 
)
overridevirtual

Send a UDP datagram and wait for one response.

Parameters
dataDatagram to send.
timeoutMaximum response wait time.
Returns
Received datagram.
Exceptions
std::system_erroron transport failure.
RPCTimeoutErrorwhen the timeout expires.

Implements profinet::rpc::IRpcTransport.

Definition at line 210 of file rpcTransport.cpp.

References endpoint, ioContext, profinet::RECEIVE_BUFFER_LENGTH, and socket.

Referenced by profinet::rpc::EpmLookup().

+ Here is the caller graph for this function:

◆ SendTo()

void profinet::rpc::RpcTransport::SendTo ( const Bytes data,
const asio::ip::udp::endpoint &  targetEndpoint 
)

Send a UDP datagram to a specific remote endpoint.

Parameters
dataDatagram to send.
targetEndpointDestination UDP endpoint.

Definition at line 183 of file rpcTransport.cpp.

References socket.

Member Data Documentation

◆ endpoint

asio::ip::udp::endpoint profinet::rpc::RpcTransport::endpoint
private

Definition at line 70 of file rpcTransport.h.

Referenced by Open(), Send(), and SendReceive().

◆ ioContext

asio::io_context& profinet::rpc::RpcTransport::ioContext
private

Definition at line 68 of file rpcTransport.h.

Referenced by Receive(), and SendReceive().

◆ socket

asio::ip::udp::socket profinet::rpc::RpcTransport::socket
private

Definition at line 69 of file rpcTransport.h.

Referenced by Close(), IsOpen(), Open(), Receive(), Send(), SendReceive(), and SendTo().


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