Deskflow 1.24.0.365
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
IArchNetwork.h
Go to the documentation of this file.
1/*
2 * Deskflow -- mouse and keyboard sharing utility
3 * SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
4 * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
5 * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
6 * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
7 */
8
9#pragma once
10
11#include <cstdint>
12#include <string>
13#include <vector>
14
15class ArchThreadImpl;
17
23class ArchSocketImpl;
24
31
39
46
48
53{
54public:
55 virtual ~IArchNetwork() = default;
57 enum class AddressFamily : uint8_t
58 {
62 };
63
65 enum class SocketType : uint8_t
66 {
69 };
70
72
77 {
78 inline static const int In = 1;
79 inline static const int Out = 2;
80 inline static const int Error = 4;
81 inline static const int Invalid = 8;
82 };
83
86 {
87 public:
90
92
95 unsigned short m_events;
96
98 unsigned short m_revents;
99 };
100
102
103
105
109
111
115
117
122 virtual void closeSocket(ArchSocket s) = 0;
123
125
128 virtual void closeSocketForRead(ArchSocket s) = 0;
129
131
134 virtual void closeSocketForWrite(ArchSocket s) = 0;
135
137
141
143
146 virtual void listenOnSocket(ArchSocket s) = 0;
147
149
159
161
170
172
186 virtual int pollSocket(PollEntry[], int num, double timeout) = 0;
187
189
194 virtual void unblockPollSocket(ArchThread thread) = 0;
195
197
203 virtual size_t readSocket(ArchSocket s, void *buf, size_t len) = 0;
204
206
212 virtual size_t writeSocket(ArchSocket s, const void *buf, size_t len) = 0;
213
215
219 virtual void throwErrorOnSocket(ArchSocket s) = 0;
220
222
226 virtual bool setNoDelayOnSocket(ArchSocket, bool noDelay) = 0;
227
229
233 virtual bool setReuseAddrOnSocket(ArchSocket, bool reuse) = 0;
234
237
240
242 virtual std::vector<ArchNetAddress> nameToAddr(const std::string &) = 0;
243
245 virtual void closeAddr(ArchNetAddress) = 0;
246
248 virtual std::string addrToName(ArchNetAddress) = 0;
249
251 virtual std::string addrToString(ArchNetAddress) = 0;
252
255
257 virtual void setAddrPort(ArchNetAddress, int port) = 0;
258
260 virtual int getAddrPort(ArchNetAddress) = 0;
261
264
266
270 virtual bool isAnyAddr(ArchNetAddress addr) = 0;
271
273
274 virtual void init() = 0;
275
276private:
280 [[noreturn]] virtual void throwError(int) const = 0;
281
285 [[noreturn]] virtual void throwNameError(int) const = 0;
286};
static void FAR int len
Definition ArchNetworkWinsock.cpp:38
static struct sockaddr FAR * addr
Definition ArchNetworkWinsock.cpp:25
static fd_set FAR fd_set FAR fd_set FAR const struct timeval FAR * timeout
Definition ArchNetworkWinsock.cpp:40
static void FAR * buf
Definition ArchNetworkWinsock.cpp:38
ArchThreadImpl * ArchThread
Opaque thread type. An opaque type representing a thread.
Definition IArchMultithread.h:54
ArchNetAddressImpl * ArchNetAddress
Opaque network address type. An opaque type representing a network address.
Definition IArchNetwork.h:45
ArchSocketImpl * ArchSocket
Opaque socket type. An opaque type representing a socket.
Definition IArchNetwork.h:30
Internal network address data. An architecture dependent type holding the necessary data for a networ...
Definition ArchNetworkBSD.h:34
Internal socket data. An architecture dependent type holding the necessary data for a socket.
Definition ArchNetworkBSD.h:27
Internal thread data. An architecture dependent type holding the necessary data for a thread.
Definition ArchMultithreadPosix.cpp:34
A socket query for poll().
Definition IArchNetwork.h:86
unsigned short m_revents
The result events.
Definition IArchNetwork.h:98
ArchSocket m_socket
The socket to query.
Definition IArchNetwork.h:89
unsigned short m_events
The events to query for.
Definition IArchNetwork.h:95
Interface for architecture dependent networking.
Definition IArchNetwork.h:53
virtual std::vector< ArchNetAddress > nameToAddr(const std::string &)=0
Convert a name to a network address.
virtual void bindSocket(ArchSocket s, ArchNetAddress addr)=0
Bind socket to address.
virtual void throwErrorOnSocket(ArchSocket s)=0
Check error on socket.
SocketType
Supported socket types.
Definition IArchNetwork.h:66
@ DataGram
Definition IArchNetwork.h:67
@ Stream
Definition IArchNetwork.h:68
virtual AddressFamily getAddrFamily(ArchNetAddress)=0
Get an address's family.
virtual bool connectSocket(ArchSocket s, ArchNetAddress addr)=0
Connect socket.
virtual bool setNoDelayOnSocket(ArchSocket, bool noDelay)=0
Turn Nagle algorithm on or off on socket.
virtual int pollSocket(PollEntry[], int num, double timeout)=0
Check socket state.
virtual std::string addrToName(ArchNetAddress)=0
Convert an address to a host name.
virtual ArchSocket acceptSocket(ArchSocket s, ArchNetAddress *addr)=0
Accept connection on socket.
virtual bool isAnyAddr(ArchNetAddress addr)=0
Test for the "any" address.
virtual void unblockPollSocket(ArchThread thread)=0
Unblock thread in pollSocket().
virtual void closeSocket(ArchSocket s)=0
Release a socket reference.
virtual bool isEqualAddr(ArchNetAddress, ArchNetAddress)=0
Test addresses for equality.
virtual bool setReuseAddrOnSocket(ArchSocket, bool reuse)=0
Turn address reuse on or off on socket.
virtual void closeSocketForWrite(ArchSocket s)=0
Close socket for further writes.
AddressFamily
Supported address families.
Definition IArchNetwork.h:58
@ INet6
Definition IArchNetwork.h:61
@ INet
Definition IArchNetwork.h:60
@ Unknown
Definition IArchNetwork.h:59
virtual ~IArchNetwork()=default
virtual ArchNetAddress newAnyAddr(AddressFamily)=0
Create an "any" network address.
virtual std::string addrToString(ArchNetAddress)=0
Convert an address to a string.
virtual ArchNetAddress copyAddr(ArchNetAddress)=0
Copy a network address.
virtual void listenOnSocket(ArchSocket s)=0
Listen for connections on socket.
virtual size_t readSocket(ArchSocket s, void *buf, size_t len)=0
Read data from socket.
virtual int getAddrPort(ArchNetAddress)=0
Get the port of an address.
virtual void closeSocketForRead(ArchSocket s)=0
Close socket for further reads.
virtual size_t writeSocket(ArchSocket s, const void *buf, size_t len)=0
Write data from socket.
virtual void setAddrPort(ArchNetAddress, int port)=0
Set the port of an address.
virtual ArchSocket copySocket(ArchSocket s)=0
Copy a socket object.
virtual void init()=0
virtual ArchSocket newSocket(AddressFamily, SocketType)=0
Create a new socket.
virtual void closeAddr(ArchNetAddress)=0
Destroy a network address.
Events for poll().
Definition IArchNetwork.h:77
static const int Out
Socket is writable.
Definition IArchNetwork.h:79
static const int Error
The socket is in an error state.
Definition IArchNetwork.h:80
static const int In
Socket is readable.
Definition IArchNetwork.h:78
static const int Invalid
The socket is invalid.
Definition IArchNetwork.h:81