EHS Embedded HTTP Server  1.5.1.173
NetworkAbstraction Class Referenceabstract

Abstracts different socket types. More...

#include <networkabstraction.h>

+ Inheritance diagram for NetworkAbstraction:

Public Member Functions

virtual void RegisterBindHelper (PrivilegedBindHelper *helper)=0
 Registers a PrivilegedBindHelper for use by this instance. More...
 
virtual void SetBindAddress (const char *bindAddress)=0
 Sets the bind address of the socket. More...
 
virtual std::string GetRemoteAddress () const =0
 Retrieves the peer address. More...
 
virtual int GetRemotePort () const =0
 Retrieves the peer's port of a connection. More...
 
virtual std::string GetLocalAddress () const =0
 Retrieves the peer address. More...
 
virtual int GetLocalPort () const =0
 Retrieves the peer's port of a connection. More...
 
virtual std::string GetAddress () const
 Retrieves the peer address. More...
 
virtual int GetPort () const
 Retrieves the peer's port of a connection. More...
 
virtual std::string GetPeer () const =0
 Combination of GetRemoteAddress and GetRemotePort. More...
 
virtual void Init (int port)=0
 Initializes a listening socket. More...
 
virtual ~NetworkAbstraction ()
 Destructor.
 
virtual ehs_socket_t GetFd () const =0
 Retrieves the underlying file descriptor. More...
 
virtual int Read (void *buf, int bufsize)=0
 Performs a read from the underlying socket. More...
 
virtual int Send (const void *buf, size_t buflen, int flags=0)=0
 Performs a send on the underlying socket. More...
 
virtual void Close ()=0
 Closes the underlying socket.
 
virtual NetworkAbstractionAccept ()=0
 Waits for an incoming connection. More...
 
virtual bool IsSecure () const =0
 Determines, whether the underlying socket is socure. More...
 
virtual void ThreadCleanup ()=0
 Handles thread specific clean up (used by OpenSSL).
 

Detailed Description

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.

Member Function Documentation

◆ Accept()

virtual NetworkAbstraction* Accept ( )
pure virtual

Waits for an incoming connection.

Returns
A new NetworkAbstraction instance which represents the client connetion.
Exceptions
Astd:runtime_error on failure.

Implemented in Socket.

◆ GetAddress()

virtual std::string GetAddress ( ) const
inlinevirtual

Retrieves the peer address.

Returns
The address of the connected peer in quad-dotted format.
Deprecated:
Use GetRemoteAddress()

Definition at line 95 of file networkabstraction.h.

References GetRemoteAddress().

+ Here is the call graph for this function:

◆ 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

Retrieves the peer's port of a connection.

Returns
The peer port.
Deprecated:
Use GetRemotePort()

Definition at line 103 of file networkabstraction.h.

References GetRemotePort().

+ Here is the call graph for this function:

◆ 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().

+ Here is the caller graph for this function:

◆ 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().

+ Here is the caller graph for this function:

◆ 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
portThe port to listen on.
Exceptions
Astd: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
bufPointer to a buffer that receives the incoming data.
bufsizeThe 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()

virtual void RegisterBindHelper ( PrivilegedBindHelper helper)
pure virtual

Registers a PrivilegedBindHelper for use by this instance.

Parameters
helperThe PrivilegedBindHelper to be used by this instance.

Implemented in Socket.

◆ Send()

virtual int Send ( const void *  buf,
size_t  buflen,
int  flags = 0 
)
pure virtual

Performs a send on the underlying socket.

Parameters
bufPointer to the data to be sent.
buflenThe number of bytes to send.
flagsAdditional 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
bindAddressThe address to bind to in quad-dotted format.

Implemented in Socket.


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