PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
rpcTransport.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <asio.hpp>
7#include <chrono>
8#include <cstdint>
9
11#include "profinet/protocol.h"
12
13namespace profinet::rpc
14{
15
18{
19 public:
22 explicit RpcTransport(asio::io_context& ioContext);
23
28 void Open(const std::string& address, std::uint16_t port, bool isListener = false) override;
29
34 Bytes Receive(std::chrono::milliseconds timeout, asio::ip::udp::endpoint& remoteEndpoint) override;
35
39 void SendTo(const Bytes& data, const asio::ip::udp::endpoint& targetEndpoint) override;
40
47 Bytes SendReceive(const Bytes& data, std::chrono::milliseconds timeout) override;
48
51 void Send(const Bytes& data) override;
52
54 void Close() noexcept override;
55
58 [[nodiscard]] bool IsOpen() const noexcept;
59
60 private:
61 asio::io_context& ioContext;
62 asio::ip::udp::socket socket;
63 asio::ip::udp::endpoint endpoint;
64};
65
66} // namespace profinet::rpc
Synchronous UDP transport used by PROFINET DCE/RPC.
void SendTo(const Bytes &data, const asio::ip::udp::endpoint &targetEndpoint) override
Send a UDP datagram to a specific remote endpoint.
bool IsOpen() const noexcept
Check whether the socket is open.
asio::io_context & ioContext
void Open(const std::string &address, std::uint16_t port, bool isListener=false) override
Open the UDP socket and configure the remote endpoint.
asio::ip::udp::socket socket
Bytes SendReceive(const Bytes &data, std::chrono::milliseconds timeout) override
Send a UDP datagram and wait for one response.
void Close() noexcept override
Close the UDP socket.
void Send(const Bytes &data) override
Send a UDP datagram without waiting for a response.
Bytes Receive(std::chrono::milliseconds timeout, asio::ip::udp::endpoint &remoteEndpoint) override
Wait for an incoming UDP datagram and capture the sender's endpoint.
asio::ip::udp::endpoint endpoint
std::vector< std::uint8_t > Bytes
Generic byte buffer alias used throughout the library for raw wire data.
Definition protocol.h:55
PROFINET protocol wire-format structures and serialization helpers.
asio::ip::udp::endpoint remoteEndpoint