PLCnext API Documentation  21.9.0.40
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
48  IpcSocket(bool blocking = true);
50  IpcSocket(const IpcSocket& arg) = delete;
52  IpcSocket(IpcSocket&& arg) = default;
54  IpcSocket& operator=(const IpcSocket& arg) = delete;
56  ~IpcSocket(void);
57 
58 private: // construction/destruction
59  IpcSocket(ISocketService *pSocket);
60 
61 public: // operations
62 
68  IpcSocketError Bind(const Arp::String& path);
69 
81  IpcSocketError Listen(size_t backlog);
82 
91  IpcSocketError Connect(const Arp::String& path);
92 
101  bool Select(SelectMode mode, Microseconds timeout, IpcSocketError& error);
102 
118  Ptr Accept(IpcSocketError& error);
119 
125  IpcSocketError Shutdown(void);
126 
132  IpcSocketError Close(void);
133 
141  int Send(const void *pBuffer, size_t length, IpcSocketError& error);
142 
150  int Receive(void *pBuffer, size_t length, IpcSocketError& error);
151 
152 private: // fields
153 
154  ISocketService *pSocketService;
155 
156 };
157 
158 }}}}
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