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) override
 Open the UDP socket and configure the remote endpoint.
 
Bytes Receive (std::chrono::milliseconds timeout, asio::ip::udp::endpoint &remoteEndpoint) override
 Wait for an incoming UDP datagram and capture the sender's endpoint.
 
void SendTo (const Bytes &data, const asio::ip::udp::endpoint &targetEndpoint) override
 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 override
 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 57 of file rpcTransport.cpp.

Member Function Documentation

◆ Close()

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

Close the UDP socket.

Implements profinet::rpc::IRpcTransport.

Definition at line 344 of file rpcTransport.cpp.

References socket.

Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

+ Here is the caller graph for this function:

◆ 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 355 of file rpcTransport.cpp.

References socket.

Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

+ Here is the caller graph for this function:

◆ Open()

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

Open the UDP socket and configure the remote endpoint.

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

Implements profinet::rpc::IRpcTransport.

Definition at line 62 of file rpcTransport.cpp.

References endpoint, and socket.

Referenced by profinet::rpc::RPCCon::EpmLookup(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

+ Here is the caller graph for this function:

◆ Receive()

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

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.

Implements profinet::rpc::IRpcTransport.

Definition at line 137 of file rpcTransport.cpp.

References completion, ioContext, and socket.

Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

+ Here is the caller graph for this function:

◆ 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 319 of file rpcTransport.cpp.

References endpoint, and socket.

Referenced by TEST_F(), TEST_F(), and TEST_F().

+ Here is the caller graph for this function:

◆ 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 236 of file rpcTransport.cpp.

References completion, endpoint, ioContext, and socket.

Referenced by profinet::rpc::RPCCon::EpmLookup(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

+ Here is the caller graph for this function:

◆ SendTo()

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

Send a UDP datagram to a specific remote endpoint.

Parameters
dataDatagram to send.
targetEndpointDestination UDP endpoint.

Implements profinet::rpc::IRpcTransport.

Definition at line 209 of file rpcTransport.cpp.

References socket.

Referenced by TEST_F(), TEST_F(), and TEST_F().

+ Here is the caller graph for this function:

Member Data Documentation

◆ endpoint

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

Definition at line 63 of file rpcTransport.h.

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

◆ ioContext

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

Definition at line 61 of file rpcTransport.h.

Referenced by Receive(), and SendReceive().

◆ socket

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

Definition at line 62 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: