PLCnext API Documentation 24.6.0.58
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#include "Arp/System/Ve/ISocketService.hpp"
13
14namespace Arp { namespace System { namespace Commons { namespace Ipc
15{
16
29{
30
31public: // typedefs/usings
32
34 typedef std::shared_ptr<IpcSocket> Ptr;
35
38
41
44
45private: // typedefs/usings
47
48public: // construction/destruction
51 IpcSocket(bool blocking = true);
53 IpcSocket(const IpcSocket& arg) = delete;
55 IpcSocket(IpcSocket&& arg) = default;
57 IpcSocket& operator=(const IpcSocket& arg) = delete;
60
61private: // construction/destruction
62 IpcSocket(ISocketService *pSocket);
63
64public: // operations
65
72
84 IpcSocketError Listen(size_t backlog);
85
95
104 bool Select(SelectMode mode, Microseconds timeout, IpcSocketError& error);
105
119 int Poll(PollMode mode, Milliseconds timeout, IpcSocketError& error);
120
137
144
149
156
164 int Send(const void *pBuffer, size_t length, IpcSocketError& error);
165
173 int Receive(void *pBuffer, size_t length, IpcSocketError& error);
174
175 virtual ISocketService::PeerCredentials GetPeerCredentials(IpcSocketError& error);
176
177private: // fields
178
179 ISocketService *pSocketService;
180
181};
182
183}}}}
Socket for interprocess communication between processes on the same controller.
Definition: IpcSocket.hpp:29
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:34
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.
Definition: ISocketService.hpp:13
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
Definition: ISocketService.hpp:260