Abstracts different socket types.
More...
#include <networkabstraction.h>
Abstracts different socket types.
This interface abstracts the differences between normal sockets and SSL sockets. There are two implementations:
-
Socket is the standard socket
-
SecureSocket is the SSL implementation
Definition at line 49 of file networkabstraction.h.
◆ Accept()
Waits for an incoming connection.
- Returns
- A new NetworkAbstraction instance which represents the client connetion.
- Exceptions
-
A | std:runtime_error on failure. |
Implemented in Socket.
◆ GetAddress()
virtual std::string GetAddress |
( |
| ) |
const |
|
inlinevirtual |
◆ GetFd()
virtual ehs_socket_t GetFd |
( |
| ) |
const |
|
pure virtual |
Retrieves the underlying file descriptor.
- Returns
- The FD/Socket of the listening socket.
Implemented in Socket.
◆ GetLocalAddress()
virtual std::string GetLocalAddress |
( |
| ) |
const |
|
pure virtual |
Retrieves the peer address.
- Returns
- The address of the connected peer in quad-dotted format.
Implemented in Socket.
◆ GetLocalPort()
virtual int GetLocalPort |
( |
| ) |
const |
|
pure virtual |
Retrieves the peer's port of a connection.
- Returns
- The peer port.
Implemented in Socket.
◆ GetPeer()
virtual std::string GetPeer |
( |
| ) |
const |
|
pure virtual |
Combination of GetRemoteAddress and GetRemotePort.
- Returns
- The address of the connected peer in quad-dotted format, followed by the port, separated by a colon.
Implemented in Socket.
◆ GetPort()
virtual int GetPort |
( |
| ) |
const |
|
inlinevirtual |
◆ GetRemoteAddress()
virtual std::string GetRemoteAddress |
( |
| ) |
const |
|
pure virtual |
Retrieves the peer address.
- Returns
- The address of the connected peer in quad-dotted format.
Implemented in Socket.
Referenced by GetAddress().
◆ GetRemotePort()
virtual int GetRemotePort |
( |
| ) |
const |
|
pure virtual |
Retrieves the peer's port of a connection.
- Returns
- The peer port.
Implemented in Socket.
Referenced by GetPort().
◆ Init()
virtual void Init |
( |
int |
port | ) |
|
|
pure virtual |
Initializes a listening socket.
If listening should be restricted to a specific address, SetBindAddress has to be called in advance.
- Parameters
-
port | The port to listen on. |
- Exceptions
-
A | std:runtime_error if initialization fails. |
Implemented in Socket.
◆ IsSecure()
virtual bool IsSecure |
( |
| ) |
const |
|
pure virtual |
Determines, whether the underlying socket is socure.
- Returns
- true, if SSL is used; false otherwise.
Implemented in Socket.
◆ Read()
virtual int Read |
( |
void * |
buf, |
|
|
int |
bufsize |
|
) |
| |
|
pure virtual |
Performs a read from the underlying socket.
- Parameters
-
buf | Pointer to a buffer that receives the incoming data. |
bufsize | The maximum number of bytes to read. |
- Returns
- The actual number of bytes that have been received or -1 if an error occured.
Implemented in Socket.
◆ RegisterBindHelper()
◆ Send()
virtual int Send |
( |
const void * |
buf, |
|
|
size_t |
buflen, |
|
|
int |
flags = 0 |
|
) |
| |
|
pure virtual |
Performs a send on the underlying socket.
- Parameters
-
buf | Pointer to the data to be sent. |
buflen | The number of bytes to send. |
flags | Additional flags for the system call. |
- Returns
- The actual number of byte that have been sent or -1 if an error occured.
Implemented in Socket.
◆ SetBindAddress()
virtual void SetBindAddress |
( |
const char * |
bindAddress | ) |
|
|
pure virtual |
Sets the bind address of the socket.
- Parameters
-
bindAddress | The address to bind to in quad-dotted format. |
Implemented in Socket.
The documentation for this class was generated from the following file: