Deskflow 1.22.0.197
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) 2012 - 2016 Symless Ltd.
4 * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
5 * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
6 */
7
8#pragma once
9
10#include "common/IInterface.h"
11#include <string>
12
13#include <vector>
14
15class ArchThreadImpl;
17
23class ArchSocketImpl;
24
31
39
46
48
53{
54public:
56 enum class AddressFamily : uint8_t
57 {
61 };
62
64 enum class SocketType : uint8_t
65 {
68 };
69
71
76 {
77 inline static const int In = 1;
78 inline static const int Out = 2;
79 inline static const int Error = 4;
80 inline static const int Invalid = 8;
81 };
82
85 {
86 public:
89
91
94 unsigned short m_events;
95
97 unsigned short m_revents;
98 };
99
101
102
104
108
110
114
116
121 virtual void closeSocket(ArchSocket s) = 0;
122
124
127 virtual void closeSocketForRead(ArchSocket s) = 0;
128
130
133 virtual void closeSocketForWrite(ArchSocket s) = 0;
134
136
140
142
145 virtual void listenOnSocket(ArchSocket s) = 0;
146
148
158
160
169
171
185 virtual int pollSocket(PollEntry[], int num, double timeout) = 0;
186
188
193 virtual void unblockPollSocket(ArchThread thread) = 0;
194
196
202 virtual size_t readSocket(ArchSocket s, void *buf, size_t len) = 0;
203
205
211 virtual size_t writeSocket(ArchSocket s, const void *buf, size_t len) = 0;
212
214
218 virtual void throwErrorOnSocket(ArchSocket s) = 0;
219
221
225 virtual bool setNoDelayOnSocket(ArchSocket, bool noDelay) = 0;
226
228
232 virtual bool setReuseAddrOnSocket(ArchSocket, bool reuse) = 0;
233
235 virtual std::string getHostName() = 0;
236
239
242
244 virtual std::vector<ArchNetAddress> nameToAddr(const std::string &) = 0;
245
247 virtual void closeAddr(ArchNetAddress) = 0;
248
250 virtual std::string addrToName(ArchNetAddress) = 0;
251
253 virtual std::string addrToString(ArchNetAddress) = 0;
254
257
259 virtual void setAddrPort(ArchNetAddress, int port) = 0;
260
262 virtual int getAddrPort(ArchNetAddress) = 0;
263
266
268
272 virtual bool isAnyAddr(ArchNetAddress addr) = 0;
273
275
276 virtual void init() = 0;
277
278private:
282 [[noreturn]] virtual void throwError(int) const = 0;
283
287 [[noreturn]] virtual void throwNameError(int) const = 0;
288};
static void FAR int len
Definition ArchNetworkWinsock.cpp:37
static struct sockaddr FAR * addr
Definition ArchNetworkWinsock.cpp:24
static fd_set FAR fd_set FAR fd_set FAR const struct timeval FAR * timeout
Definition ArchNetworkWinsock.cpp:39
static void FAR * buf
Definition ArchNetworkWinsock.cpp:37
ArchThreadImpl * ArchThread
Opaque thread type. An opaque type representing a thread.
Definition IArchMultithread.h:53
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:85
unsigned short m_revents
The result events.
Definition IArchNetwork.h:97
ArchSocket m_socket
The socket to query.
Definition IArchNetwork.h:88
unsigned short m_events
The events to query for.
Definition IArchNetwork.h:94
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:65
@ DataGram
Definition IArchNetwork.h:66
@ Stream
Definition IArchNetwork.h:67
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:57
@ INet6
Definition IArchNetwork.h:60
@ INet
Definition IArchNetwork.h:59
@ Unknown
Definition IArchNetwork.h:58
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 std::string getHostName()=0
Return local host's name.
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.
Base class of interfaces.
Definition IInterface.h:18
Events for poll()
Definition IArchNetwork.h:76
static const int Out
Socket is writable.
Definition IArchNetwork.h:78
static const int Error
The socket is in an error state.
Definition IArchNetwork.h:79
static const int In
Socket is readable.
Definition IArchNetwork.h:77
static const int Invalid
The socket is invalid.
Definition IArchNetwork.h:80