Deskflow 1.22.0.197
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
IArchNetwork Class Referenceabstract

Interface for architecture dependent networking. More...

#include <IArchNetwork.h>

Inheritance diagram for IArchNetwork:
Collaboration diagram for IArchNetwork:

Classes

class  PollEntry
 A socket query for poll() More...
struct  PollEventMask
 Events for poll() More...

Public Types

enum class  AddressFamily : uint8_t { Unknown , INet , INet6 }
 Supported address families. More...
enum class  SocketType : uint8_t { DataGram , Stream }
 Supported socket types. More...

manipulators

virtual ArchSocket newSocket (AddressFamily, SocketType)=0
 Create a new socket.
virtual ArchSocket copySocket (ArchSocket s)=0
 Copy a socket object.
virtual void closeSocket (ArchSocket s)=0
 Release a socket reference.
virtual void closeSocketForRead (ArchSocket s)=0
 Close socket for further reads.
virtual void closeSocketForWrite (ArchSocket s)=0
 Close socket for further writes.
virtual void bindSocket (ArchSocket s, ArchNetAddress addr)=0
 Bind socket to address.
virtual void listenOnSocket (ArchSocket s)=0
 Listen for connections on socket.
virtual ArchSocket acceptSocket (ArchSocket s, ArchNetAddress *addr)=0
 Accept connection on socket.
virtual bool connectSocket (ArchSocket s, ArchNetAddress addr)=0
 Connect socket.
virtual int pollSocket (PollEntry[], int num, double timeout)=0
 Check socket state.
virtual void unblockPollSocket (ArchThread thread)=0
 Unblock thread in pollSocket()
virtual size_t readSocket (ArchSocket s, void *buf, size_t len)=0
 Read data from socket.
virtual size_t writeSocket (ArchSocket s, const void *buf, size_t len)=0
 Write data from socket.
virtual void throwErrorOnSocket (ArchSocket s)=0
 Check error on socket.
virtual bool setNoDelayOnSocket (ArchSocket, bool noDelay)=0
 Turn Nagle algorithm on or off on socket.
virtual bool setReuseAddrOnSocket (ArchSocket, bool reuse)=0
 Turn address reuse on or off on socket.
virtual std::string getHostName ()=0
 Return local host's name.
virtual ArchNetAddress newAnyAddr (AddressFamily)=0
 Create an "any" network address.
virtual ArchNetAddress copyAddr (ArchNetAddress)=0
 Copy a network address.
virtual std::vector< ArchNetAddressnameToAddr (const std::string &)=0
 Convert a name to a network address.
virtual void closeAddr (ArchNetAddress)=0
 Destroy a network address.
virtual std::string addrToName (ArchNetAddress)=0
 Convert an address to a host name.
virtual std::string addrToString (ArchNetAddress)=0
 Convert an address to a string.
virtual AddressFamily getAddrFamily (ArchNetAddress)=0
 Get an address's family.
virtual void setAddrPort (ArchNetAddress, int port)=0
 Set the port of an address.
virtual int getAddrPort (ArchNetAddress)=0
 Get the port of an address.
virtual bool isEqualAddr (ArchNetAddress, ArchNetAddress)=0
 Test addresses for equality.
virtual bool isAnyAddr (ArchNetAddress addr)=0
 Test for the "any" address.
virtual void init ()=0

Additional Inherited Members

Public Member Functions inherited from IInterface
virtual ~IInterface ()=default
 Interface destructor does nothing.

Detailed Description

Interface for architecture dependent networking.

This interface defines the networking operations required by deskflow. Each architecture must implement this interface.

Member Enumeration Documentation

◆ AddressFamily

enum class IArchNetwork::AddressFamily : uint8_t
strong

Supported address families.

Enumerator
Unknown 
INet 
INet6 

◆ SocketType

enum class IArchNetwork::SocketType : uint8_t
strong

Supported socket types.

Enumerator
DataGram 
Stream 

Member Function Documentation

◆ acceptSocket()

virtual ArchSocket IArchNetwork::acceptSocket ( ArchSocket s,
ArchNetAddress * addr )
pure virtual

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.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ addrToName()

virtual std::string IArchNetwork::addrToName ( ArchNetAddress )
pure virtual

Convert an address to a host name.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ addrToString()

virtual std::string IArchNetwork::addrToString ( ArchNetAddress )
pure virtual

Convert an address to a string.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ bindSocket()

virtual void IArchNetwork::bindSocket ( ArchSocket s,
ArchNetAddress addr )
pure virtual

Bind socket to address.

Binds socket s to the address addr.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ closeAddr()

virtual void IArchNetwork::closeAddr ( ArchNetAddress )
pure virtual

Destroy a network address.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ closeSocket()

virtual void IArchNetwork::closeSocket ( ArchSocket s)
pure virtual

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.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ closeSocketForRead()

virtual void IArchNetwork::closeSocketForRead ( ArchSocket s)
pure virtual

Close socket for further reads.

Calling this disallows future reads on socket s.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ closeSocketForWrite()

virtual void IArchNetwork::closeSocketForWrite ( ArchSocket s)
pure virtual

Close socket for further writes.

Calling this disallows future writes on socket s.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ connectSocket()

virtual bool IArchNetwork::connectSocket ( ArchSocket s,
ArchNetAddress addr )
pure virtual

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.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ copyAddr()

virtual ArchNetAddress IArchNetwork::copyAddr ( ArchNetAddress )
pure virtual

Copy a network address.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ copySocket()

virtual ArchSocket IArchNetwork::copySocket ( ArchSocket s)
pure virtual

Copy a socket object.

Returns a reference to to socket referred to by s.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ getAddrFamily()

virtual AddressFamily IArchNetwork::getAddrFamily ( ArchNetAddress )
pure virtual

Get an address's family.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ getAddrPort()

virtual int IArchNetwork::getAddrPort ( ArchNetAddress )
pure virtual

Get the port of an address.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ getHostName()

virtual std::string IArchNetwork::getHostName ( )
pure virtual

Return local host's name.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ init()

virtual void IArchNetwork::init ( )
pure virtual

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ isAnyAddr()

virtual bool IArchNetwork::isAnyAddr ( ArchNetAddress addr)
pure virtual

Test for the "any" address.

Returns true if addr is the "any" address. newAnyAddr() returns an "any" address.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ isEqualAddr()

virtual bool IArchNetwork::isEqualAddr ( ArchNetAddress ,
ArchNetAddress  )
pure virtual

Test addresses for equality.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ listenOnSocket()

virtual void IArchNetwork::listenOnSocket ( ArchSocket s)
pure virtual

Listen for connections on socket.

Causes the socket s to begin listening for incoming connections.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ nameToAddr()

virtual std::vector< ArchNetAddress > IArchNetwork::nameToAddr ( const std::string & )
pure virtual

Convert a name to a network address.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ newAnyAddr()

virtual ArchNetAddress IArchNetwork::newAnyAddr ( AddressFamily )
pure virtual

Create an "any" network address.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ newSocket()

virtual ArchSocket IArchNetwork::newSocket ( AddressFamily ,
SocketType  )
pure virtual

Create a new socket.

The socket is an opaque data type.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ pollSocket()

virtual int IArchNetwork::pollSocket ( PollEntry [],
int num,
double timeout )
pure virtual

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)

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ readSocket()

virtual size_t IArchNetwork::readSocket ( ArchSocket s,
void * buf,
size_t len )
pure virtual

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.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ setAddrPort()

virtual void IArchNetwork::setAddrPort ( ArchNetAddress ,
int port )
pure virtual

Set the port of an address.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ setNoDelayOnSocket()

virtual bool IArchNetwork::setNoDelayOnSocket ( ArchSocket ,
bool noDelay )
pure virtual

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.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ setReuseAddrOnSocket()

virtual bool IArchNetwork::setReuseAddrOnSocket ( ArchSocket ,
bool reuse )
pure virtual

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.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ throwErrorOnSocket()

virtual void IArchNetwork::throwErrorOnSocket ( ArchSocket s)
pure virtual

Check error on socket.

If the socket s is in an error state then throws an appropriate XArchNetwork exception.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ unblockPollSocket()

virtual void IArchNetwork::unblockPollSocket ( ArchThread thread)
pure virtual

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.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.

◆ writeSocket()

virtual size_t IArchNetwork::writeSocket ( ArchSocket s,
const void * buf,
size_t len )
pure virtual

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.

Implemented in ArchNetworkBSD, and ArchNetworkWinsock.


The documentation for this class was generated from the following file: