PLCnext API Documentation 25.0.2.69
IpcSocket.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
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/Commons/Ipc/PeerCredentials.hpp"
13
14// forwards
15namespace Arp { namespace System { namespace Ve
16{
17class ISocketService;
18}}}
19
20namespace Arp { namespace System { namespace Commons { namespace Ipc
21{
22
35{
36
37public: // typedefs/usings
38
40 typedef std::shared_ptr<IpcSocket> Ptr;
41
44
47
50
51private: // typedefs/usings
52 using ISocketService = Arp::System::Ve::ISocketService;
53
54public: // construction/destruction
55 IpcSocket(bool blocking = true);
57 IpcSocket(const IpcSocket& arg) = delete;
59 IpcSocket(IpcSocket&& arg) = default;
61 IpcSocket& operator=(const IpcSocket& arg) = delete;
62
63 ~IpcSocket(void);
64
65private: // construction/destruction
66 IpcSocket(ISocketService *pSocket);
67
68public: // operations
69 IpcSocketError Bind(const Arp::String& path);
70 IpcSocketError Listen(size_t backlog);
72 bool Select(SelectMode mode, Microseconds timeout, IpcSocketError& error);
73 int Poll(PollMode mode, Milliseconds timeout, IpcSocketError& error);
78 int Send(const void *pBuffer, size_t length, IpcSocketError& error);
79 int Receive(void *pBuffer, size_t length, IpcSocketError& error);
81
82private: // fields
83 ISocketService *pSocketService;
84};
85
86}}}}
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39
Socket for interprocess communication between processes on the same controller.
Definition: IpcSocket.hpp:35
int Poll(PollMode mode, Milliseconds timeout, IpcSocketError &error)
Checks if an i/o operation can be processed without blocking.
Definition: IpcSocket.cpp:134
~IpcSocket(void)
Closes the socket and releases all ressources.
Definition: IpcSocket.cpp:28
int Receive(void *pBuffer, size_t length, IpcSocketError &error)
Reads data from connected socket.
Definition: IpcSocket.cpp:256
IpcSocket & operator=(const IpcSocket &arg)=delete
Assignment operator is deleted.
IpcSocket(bool blocking=true)
Constructs a new socket for interprocess communication.
Definition: IpcSocket.cpp:15
bool Select(SelectMode mode, Microseconds timeout, IpcSocketError &error)
Checks if an i/o operation can be performed without blocking the calling thread.
Definition: IpcSocket.cpp:105
std::shared_ptr< IpcSocket > Ptr
Contextual definition of pointer type.
Definition: IpcSocket.hpp:40
IpcSocketError Listen(size_t backlog)
Marks this socket as a passive socket that accepts incoming connection requests.
Definition: IpcSocket.cpp:67
Ptr Accept(IpcSocketError &error)
Accepts a pending connection request.
Definition: IpcSocket.cpp:165
PeerCredentials GetPeerCredentials(IpcSocketError &error)
Reads peer credentials from connected socket.
Definition: IpcSocket.cpp:277
IpcSocketError Connect(const Arp::String &path)
Tries to connect with a remote socket.
Definition: IpcSocket.cpp:86
IpcSocketError Shutdown(void)
Shuts down a connection.
Definition: IpcSocket.cpp:191
IpcSocketError Bind(const Arp::String &path)
Assigns an address to this socket so that other process can connect with it.
Definition: IpcSocket.cpp:45
int Send(const void *pBuffer, size_t length, IpcSocketError &error)
Transmit data over the socket that is in a connected state.
Definition: IpcSocket.cpp:233
IpcSocket(const IpcSocket &arg)=delete
Copy constructor is deleted.
IpcSocketError Close(void)
Closes the socket. This ends all communication on the socket.
Definition: IpcSocket.cpp:215
IpcSocket(IpcSocket &&arg)=default
Move constructor.
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
This struct holds credentials of a UnixDomainSocket Peer
Definition: PeerCredentials.hpp:15