PLCnext API Documentation  21.0.0.35466
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/SelectMode.hpp"
9 #include "Arp/System/Commons/Ipc/IpcSocketError.hpp"
10 
11 // forwards
12 namespace Arp { namespace System { namespace Ve
13 {
14 class ISocketService;
15 }}}
16 
17 namespace Arp { namespace System { namespace Commons { namespace Ipc
18 {
19 
31 class IpcSocket
32 {
33 
34 public: // typedefs/usings
35 
37  typedef std::shared_ptr<IpcSocket> Ptr;
38 
41 
42 private: // typedefs/usings
43  using ISocketService = Arp::System::Ve::ISocketService;
44 
45 public: // construction/destruction
46 
50  IpcSocket(bool blocking = true);
51 
53  ~IpcSocket(void);
54 
55 private: // construction/destruction
56  IpcSocket(ISocketService *pSocket);
57 
58 public: // operations
59 
65  IpcSocketError Bind(const Arp::String& path);
66 
78  IpcSocketError Listen(size_t backlog);
79 
88  IpcSocketError Connect(const Arp::String& path);
89 
98  bool Select(SelectMode mode, Microseconds timeout, IpcSocketError& error);
99 
115  Ptr Accept(IpcSocketError& error);
116 
122  IpcSocketError Shutdown(void);
123 
129  IpcSocketError Close(void);
130 
138  int Send(const void *pBuffer, size_t length, IpcSocketError& error);
139 
147  int Receive(void *pBuffer, size_t length, IpcSocketError& error);
148 
149 private: // fields
150 
151  ISocketService *pSocketService;
152 
153 };
154 
155 }}}}
std::chrono::microseconds Microseconds
The Arp Microseconds unit class.
Definition: TypeSystem.h:34
Root namespace for the PLCnext API
Socket for interprocess communication between processes on the same controller.
Definition: IpcSocket.hpp:31
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:37