Deskflow 1.22.0.197
Keyboard and mouse sharing utility
|
Berkeley (BSD) sockets implementation of IArchNetwork. More...
#include <ArchNetworkBSD.h>
Classes | |
struct | Deps |
Public Member Functions | |
ArchNetworkBSD (std::shared_ptr< Deps > deps=std::make_shared< Deps >()) | |
ArchNetworkBSD (ArchNetworkBSD const &)=delete | |
ArchNetworkBSD (ArchNetworkBSD &&)=delete | |
~ArchNetworkBSD () override=default | |
ArchNetworkBSD & | operator= (ArchNetworkBSD const &)=delete |
ArchNetworkBSD & | operator= (ArchNetworkBSD &&)=delete |
void | init () override |
ArchSocket | newSocket (AddressFamily, SocketType) override |
Create a new socket. | |
ArchSocket | copySocket (ArchSocket s) override |
Copy a socket object. | |
void | closeSocket (ArchSocket s) override |
Release a socket reference. | |
void | closeSocketForRead (ArchSocket s) override |
Close socket for further reads. | |
void | closeSocketForWrite (ArchSocket s) override |
Close socket for further writes. | |
void | bindSocket (ArchSocket s, ArchNetAddress addr) override |
Bind socket to address. | |
void | listenOnSocket (ArchSocket s) override |
Listen for connections on socket. | |
ArchSocket | acceptSocket (ArchSocket s, ArchNetAddress *addr) override |
Accept connection on socket. | |
bool | connectSocket (ArchSocket s, ArchNetAddress name) override |
Connect socket. | |
int | pollSocket (PollEntry[], int num, double timeout) override |
Check socket state. | |
void | unblockPollSocket (ArchThread thread) override |
Unblock thread in pollSocket() | |
size_t | readSocket (ArchSocket s, void *buf, size_t len) override |
Read data from socket. | |
size_t | writeSocket (ArchSocket s, const void *buf, size_t len) override |
Write data from socket. | |
void | throwErrorOnSocket (ArchSocket) override |
Check error on socket. | |
bool | setNoDelayOnSocket (ArchSocket, bool noDelay) override |
Turn Nagle algorithm on or off on socket. | |
bool | setReuseAddrOnSocket (ArchSocket, bool reuse) override |
Turn address reuse on or off on socket. | |
std::string | getHostName () override |
Return local host's name. | |
ArchNetAddress | newAnyAddr (AddressFamily) override |
Create an "any" network address. | |
ArchNetAddress | copyAddr (ArchNetAddress) override |
Copy a network address. | |
std::vector< ArchNetAddress > | nameToAddr (const std::string &) override |
Convert a name to a network address. | |
void | closeAddr (ArchNetAddress) override |
Destroy a network address. | |
std::string | addrToName (ArchNetAddress) override |
Convert an address to a host name. | |
std::string | addrToString (ArchNetAddress) override |
Convert an address to a string. | |
AddressFamily | getAddrFamily (ArchNetAddress) override |
Get an address's family. | |
void | setAddrPort (ArchNetAddress, int port) override |
Set the port of an address. | |
int | getAddrPort (ArchNetAddress) override |
Get the port of an address. | |
bool | isAnyAddr (ArchNetAddress) override |
Test for the "any" address. | |
bool | isEqualAddr (ArchNetAddress, ArchNetAddress) override |
Test addresses for equality. | |
Public Member Functions inherited from IInterface | |
virtual | ~IInterface ()=default |
Interface destructor does nothing. |
Additional Inherited Members | |
Public Types inherited from IArchNetwork | |
enum class | AddressFamily : uint8_t { Unknown , INet , INet6 } |
Supported address families. More... | |
enum class | SocketType : uint8_t { DataGram , Stream } |
Supported socket types. More... |
Berkeley (BSD) sockets implementation of IArchNetwork.
|
inlineexplicit |
|
delete |
|
delete |
|
overridedefault |
|
overridevirtual |
Accept connection on socket.
Accepts a connection on socket s
, returning a new socket for the connection and filling in addr
with the address of the remote end. addr
may be nullptr if the remote address isn't required. The original socket s
is unaffected and remains in the listening state. The new socket shares most of the properties of s
except it's not in the listening state and it's connected. Returns nullptr if there are no pending connection requests.
Implements IArchNetwork.
|
overridevirtual |
Convert an address to a host name.
Implements IArchNetwork.
|
overridevirtual |
Convert an address to a string.
Implements IArchNetwork.
|
overridevirtual |
|
overridevirtual |
Destroy a network address.
Implements IArchNetwork.
|
overridevirtual |
Release a socket reference.
Deletes the given socket object. This does not destroy the socket the object referred to until there are no remaining references for the socket.
Implements IArchNetwork.
|
overridevirtual |
Close socket for further reads.
Calling this disallows future reads on socket s
.
Implements IArchNetwork.
|
overridevirtual |
Close socket for further writes.
Calling this disallows future writes on socket s
.
Implements IArchNetwork.
|
overridevirtual |
Connect socket.
Connects the socket s
to the remote address addr
. Returns true if the connection succeed immediately, false if the connection is in progress, and throws if the connection failed immediately. If it returns false, pollSocket()
can be used to wait on the socket for writing to detect when the connection finally succeeds or fails.
Implements IArchNetwork.
|
overridevirtual |
Copy a network address.
Implements IArchNetwork.
|
overridevirtual |
|
overridevirtual |
Get an address's family.
Implements IArchNetwork.
|
overridevirtual |
Get the port of an address.
Implements IArchNetwork.
|
overridevirtual |
Return local host's name.
Implements IArchNetwork.
|
overridevirtual |
Implements IArchNetwork.
|
overridevirtual |
Test for the "any" address.
Returns true if addr
is the "any" address. newAnyAddr()
returns an "any" address.
Implements IArchNetwork.
|
overridevirtual |
Test addresses for equality.
Implements IArchNetwork.
|
overridevirtual |
Listen for connections on socket.
Causes the socket s
to begin listening for incoming connections.
Implements IArchNetwork.
|
overridevirtual |
Convert a name to a network address.
Implements IArchNetwork.
|
overridevirtual |
Create an "any" network address.
Implements IArchNetwork.
|
overridevirtual |
|
delete |
|
delete |
Check socket state.
Tests the state of num
sockets for readability and/or writability. Waits up to timeout
seconds for some socket to become readable and/or writable (or indefinitely if timeout
< 0). Returns the number of sockets that were readable (if readability was being queried) or writable (if writablility was being queried) and sets the m_revents
members of the entries. PollEventMask::Error
and PollEventMask::Invalid
are set in m_revents
as appropriate. If a socket indicates PollEventMask::Error
then throwErrorOnSocket()
can be used to determine the type of error. Returns 0 immediately regardless of the timeout
if no valid sockets are selected for testing.
(Cancellation point)
Implements IArchNetwork.
|
overridevirtual |
Read data from socket.
Read up to len
bytes from socket s
in buf
and return the number of bytes read. The number of bytes can be less than len
if not enough data is available. Returns 0 if the remote end has disconnected and/or there is no more queued received data.
Implements IArchNetwork.
|
overridevirtual |
Set the port of an address.
Implements IArchNetwork.
|
overridevirtual |
Turn Nagle algorithm on or off on socket.
Set socket to send messages immediately (true) or to collect small messages into one packet (false). Returns the previous state.
Implements IArchNetwork.
|
overridevirtual |
Turn address reuse on or off on socket.
Allows the address this socket is bound to to be reused while in the TIME_WAIT state. Returns the previous state.
Implements IArchNetwork.
|
overridevirtual |
Check error on socket.
If the socket s
is in an error state then throws an appropriate XArchNetwork exception.
Implements IArchNetwork.
|
overridevirtual |
Unblock thread in pollSocket()
Cause a thread that's in a pollSocket() call to return. This call may return before the thread is unblocked. If the thread is not in a pollSocket() call this call has no effect.
Implements IArchNetwork.
|
overridevirtual |
Write data from socket.
Write up to len
bytes to socket s
from buf
and return the number of bytes written. The number of bytes can be less than len
if the remote end disconnected or the internal buffers fill up.
Implements IArchNetwork.