EHS Embedded HTTP Server  1.5.0.132
NetworkAbstraction Class Reference

Abstracts different socket types. More...

#include <networkabstraction.h>

+ Inheritance diagram for NetworkAbstraction:

List of all members.

Public Member Functions

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

Member Function Documentation

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.

virtual std::string GetAddress ( ) const [inline, virtual]

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:

virtual ehs_socket_t GetFd ( ) const [pure virtual]

Retrieves the underlying file descriptor.

Returns:
The FD/Socket of the listening socket.

Implemented in Socket.

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.

virtual int GetLocalPort ( ) const [pure virtual]

Retrieves the peer's port of a connection.

Returns:
The peer port.

Implemented in Socket.

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.

virtual int GetPort ( ) const [inline, virtual]

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:

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:

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:

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.

virtual bool IsSecure ( ) const [pure virtual]

Determines, whether the underlying socket is socure.

Returns:
true, if SSL is used; false otherwise.

Implemented in Socket.

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.

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.

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.

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: