PLCnext API Documentation  22.3.0.20
IpcSocket.hpp
1 //
3 // Copyright PHOENIX CONTACT Electronics GmbH
4 //
6 #pragma once
7 #include "Arp/System/Core/Arp.h"
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
14 namespace Arp { namespace System { namespace Ve
15 {
16 class ISocketService;
17 }}}
18 
19 namespace Arp { namespace System { namespace Commons { namespace Ipc
20 {
21 
33 class IpcSocket
34 {
35 
36 public: // typedefs/usings
37 
39  typedef std::shared_ptr<IpcSocket> Ptr;
40 
43 
46 
49 
50 private: // typedefs/usings
51  using ISocketService = Arp::System::Ve::ISocketService;
52 
53 public: // 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;
64  ~IpcSocket(void);
65 
66 private: // construction/destruction
67  IpcSocket(ISocketService *pSocket);
68 
69 public: // operations
70 
76  IpcSocketError Bind(const Arp::String& path);
77 
89  IpcSocketError Listen(size_t backlog);
90 
99  IpcSocketError Connect(const Arp::String& path);
100 
109  bool Select(SelectMode mode, Microseconds timeout, IpcSocketError& error);
110 
124  int Poll(PollMode mode, Milliseconds timeout, IpcSocketError& error);
125 
141  Ptr Accept(IpcSocketError& error);
142 
148  IpcSocketError Shutdown(void);
149 
154 
160  IpcSocketError Close(void);
161 
169  int Send(const void *pBuffer, size_t length, IpcSocketError& error);
170 
178  int Receive(void *pBuffer, size_t length, IpcSocketError& error);
179 
180 private: // fields
181 
182  ISocketService *pSocketService;
183 
184 };
185 
186 }}}}
std::chrono::milliseconds Milliseconds
The Arp Milliseconds unit class.
Definition: TypeSystem.h:36
A request to send or receive data was disallowed because the socket had already been shut down in tha...
std::chrono::microseconds Microseconds
The Arp Microseconds unit class.
Definition: TypeSystem.h:34
PollMode
This enum is used to specifiy the poll mode of the <cref name="Socket::Poll"> operation.
Definition: PollMode.hpp:14
Root namespace for the PLCnext API
Socket for interprocess communication between processes on the same controller.
Definition: IpcSocket.hpp:33
ShutdownMode
This enum is used to specifiy the shutdown mode of the <cref name="Socket::Shutdown(ShutdownMode)"> o...
Definition: ShutdownMode.hpp:14
SelectMode
Modes for Select call to check different data channels.
Definition: SelectMode.hpp:13
System components used by the System, Device, Plc or Io domains.
IpcSocketError
Enumeration of possible error return codes from IpcSocket operations.
Definition: IpcSocketError.hpp:13
std::shared_ptr< IpcSocket > Ptr
Contextual definition of pointer type.
Definition: IpcSocket.hpp:39