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,
29 bool isListener = false);
30
36 std::chrono::milliseconds timeout,
37 asio::ip::udp::endpoint& remoteEndpoint);
38
42 void SendTo(
43 const Bytes& data,
44 const asio::ip::udp::endpoint& targetEndpoint);
45
53 const Bytes& data,
54 std::chrono::milliseconds timeout) override;
55
58 void Send(const Bytes& data) override;
59
61 void Close() noexcept;
62
65 [[nodiscard]] bool IsOpen() const noexcept;
66
67 private:
68 asio::io_context& ioContext;
69 asio::ip::udp::socket socket;
70 asio::ip::udp::endpoint endpoint;
71};
72
73} // namespace profinet::rpc
Synchronous UDP transport used by PROFINET DCE/RPC.
void Close() noexcept
Close the UDP socket.
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)
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.
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 Send(const Bytes &data) override
Send a UDP datagram without waiting for a response.
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:52
PROFINET protocol wire-format structures and serialization helpers.