PLCnext API Documentation 23.6.0.37
IpcSocket.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include "Arp/System/Commons/Net/PollMode.hpp"
9#include "Arp/System/Commons/Net/SelectMode.hpp"
10#include "Arp/System/Commons/Net/ShutdownMode.hpp"
11#include "Arp/System/Commons/Ipc/IpcSocketError.hpp"
12
13// forwards
14namespace Arp { namespace System { namespace Ve
15{
16class ISocketService;
17}}}
18
19namespace Arp { namespace System { namespace Commons { namespace Ipc
20{
21
34{
35
36public: // typedefs/usings
37
39 typedef std::shared_ptr<IpcSocket> Ptr;
40
43
46
49
50private: // typedefs/usings
51 using ISocketService = Arp::System::Ve::ISocketService;
52
53public: // construction/destruction
56 IpcSocket(bool blocking = true);
58 IpcSocket(const IpcSocket& arg) = delete;
60 IpcSocket(IpcSocket&& arg) = default;
62 IpcSocket& operator=(const IpcSocket& arg) = delete;
65
66private: // construction/destruction
67 IpcSocket(ISocketService *pSocket);
68
69public: // operations
70
77
89 IpcSocketError Listen(size_t backlog);
90
100
109 bool Select(SelectMode mode, Microseconds timeout, IpcSocketError& error);
110
124 int Poll(PollMode mode, Milliseconds timeout, IpcSocketError& error);
125
142
149
154
161
169 int Send(const void *pBuffer, size_t length, IpcSocketError& error);
170
178 int Receive(void *pBuffer, size_t length, IpcSocketError& error);
179
180private: // fields
181
182 ISocketService *pSocketService;
183
184};
185
186}}}}
Socket for interprocess communication between processes on the same controller.
Definition: IpcSocket.hpp:34
int Poll(PollMode mode, Milliseconds timeout, IpcSocketError &error)
Checks if an i/o operation can be processed without blocking.
~IpcSocket(void)
Closes the socket and releases all ressources.
int Receive(void *pBuffer, size_t length, IpcSocketError &error)
Reads data from connected socket.
IpcSocket & operator=(const IpcSocket &arg)=delete
Assignment operator is deleted.
IpcSocket(bool blocking=true)
Constructs a new socket for interprocess communication.
bool Select(SelectMode mode, Microseconds timeout, IpcSocketError &error)
Checks if an i/o operation can be performed without blocking the calling thread.
std::shared_ptr< IpcSocket > Ptr
Contextual definition of pointer type.
Definition: IpcSocket.hpp:39
Ptr Accept(IpcSocketError &error)
Accepts a pending connection request.
IpcSocketError Listen(size_t backlog)
Marks this socket as a passive socket that accepts incoming connection requests.
IpcSocketError Connect(const Arp::String &path)
Tries to connect with a remote socket.
IpcSocketError Shutdown(void)
Shuts down a connection.
IpcSocketError Bind(const Arp::String &path)
Assigns an address to this socket so that other process can connect with it.
int Send(const void *pBuffer, size_t length, IpcSocketError &error)
Transmit data over the socket that is in a connected state.
IpcSocket(const IpcSocket &arg)=delete
Copy constructor is deleted.
IpcSocketError Shutdown(ShutdownMode mode)
Shuts down a connection.
IpcSocketError Close(void)
Closes the socket. This ends all communication on the socket.
IpcSocket(IpcSocket &&arg)=default
Move constructor.
std::chrono::milliseconds Milliseconds
The Arp Milliseconds unit class.
Definition: TypeSystem.h:52
std::chrono::microseconds Microseconds
The Arp Microseconds unit class.
Definition: TypeSystem.h:49
@ System
System components used by the System, Device, Plc or Io domains.
IpcSocketError
Enumeration of possible error return codes from IpcSocket operations.
Definition: IpcSocketError.hpp:14
PollMode
This enum is used to specifiy the poll mode of the <cref name="Socket::Poll" > operation.
Definition: PollMode.hpp:15
SelectMode
Modes for Select call to check different data channels.
Definition: SelectMode.hpp:14
ShutdownMode
This enum is used to specifiy the shutdown mode of the <cref name="Socket::Shutdown(ShutdownMode)" > ...
Definition: ShutdownMode.hpp:15
Root namespace for the PLCnext API