FARGOS/VISTA Object Management Environment Core  ..
FARGOS/VISTA Object Management Environment Core Table of Contents
HTTPembeddedServerBase Class Referenceabstract

Core embedded HTTP server logic. More...

#include <HTTPembeddedServer.hpp>

+ Inheritance diagram for HTTPembeddedServerBase:

Public Member Functions

 HTTPembeddedServerBase (uint16_t port, void *extraData=nullptr, const char *useServerName=nullptr, uint32_t useBfrSize=0, uint16_t maxEventLength=0)
 Configures the HTTP server for listening on the indicated port. More...
 
virtual ~HTTPembeddedServerBase ()
 
void setBufferSize (uint32_t bfrSize)
 Alter buffer size used for new accepted client connections. More...
 
void setHTTPeventLength (uint32_t maxLen)
 Alter maximum length of an HTTP event used for new accepted connections. More...
 
const char * getServerName () const
 Returns the name associated with the HTTP server. More...
 
int startHTTPlisten ()
 Start the HTTP server. More...
 
int stopHTTPlisten (const char *reason)
 Stop the HTTP server. More...
 
int waitForHTTPstop ()
 Wait for server to cease operations. More...
 
virtual HTTP_SessionRecordacceptNewConnection (IO_Processor *io, CircularBufferManager *mgr, const GenericSocketAddress *from, void *extraData)=0
 

Public Attributes

void * userData
 
OS_SOCKET_TYPE listenDescriptor
 
uint32_t bufferSize
 
uint16_t maxHTTPeventLength
 
uint16_t listenPort
 
bool stopAccepting
 
bool listenActive
 

Static Protected Member Functions

static int readHTTPstream (SharedBufferAllocRecord *rec, IO_Processor *controller)
 
static void * startHTTPacceptThread (void *arg)
 

Protected Attributes

char serverName [64]
 
pthread_t acceptThreadID
 

Detailed Description

Core embedded HTTP server logic.

Invokes the abstract function acceptNewConnection() to obtain desired per-session application logic.

The templatized HTTPembeddedServer<> class provides a convenient typed interface and is how most user implementations create the HTTP server.

Constructor & Destructor Documentation

◆ HTTPembeddedServerBase()

HTTPembeddedServerBase::HTTPembeddedServerBase ( uint16_t  port,
void *  extraData = nullptr,
const char *  useServerName = nullptr,
uint32_t  useBfrSize = 0,
uint16_t  maxEventLength = 0 
)
inline

Configures the HTTP server for listening on the indicated port.

Parameters
portspecifies the TCP port onto which incoming connections will be accepted.
extraDatawill be passed to each of the HTTP_SessionRecord objects that are created.
useServerNameallows an alternate server name to be specified; the default uses the host's name.
useBfrSizeallows the buffer size to be specified. If 0, which is the default, the buffer size will be determined based on the maximum event size.
maxEventLengthallows the maximum size of a single event to be specified. If 0, the default size will be used.

NOTE: the server is not started until startHTTPlisten() is called.

References bufferSize, listenActive, listenPort, maxHTTPeventLength, safe_strcpy, serverName, stopAccepting, and userData.

◆ ~HTTPembeddedServerBase()

virtual HTTPembeddedServerBase::~HTTPembeddedServerBase ( )
inlinevirtual

Member Function Documentation

◆ acceptNewConnection()

virtual HTTP_SessionRecord* HTTPembeddedServerBase::acceptNewConnection ( IO_Processor io,
CircularBufferManager mgr,
const GenericSocketAddress from,
void *  extraData 
)
pure virtual

After the HTTP server has accepted an incoming connection, a new session object is created via a call to acceptNewConnection().

NOTE: this is an abstract function which must be implemented by the subclass realizing the server implementation.

Implemented in HTTPembeddedServer< ACCEPT_CLASS, USER_CLASS >.

◆ getServerName()

const char* HTTPembeddedServerBase::getServerName ( ) const
inline

Returns the name associated with the HTTP server.

References serverName.

◆ readHTTPstream()

◆ setBufferSize()

void HTTPembeddedServerBase::setBufferSize ( uint32_t  bfrSize)
inline

Alter buffer size used for new accepted client connections.

References bufferSize.

◆ setHTTPeventLength()

void HTTPembeddedServerBase::setHTTPeventLength ( uint32_t  maxLen)
inline

Alter maximum length of an HTTP event used for new accepted connections.

References maxHTTPeventLength.

◆ startHTTPacceptThread()

void * HTTPembeddedServerBase::startHTTPacceptThread ( void *  arg)
staticprotected

◆ startHTTPlisten()

int HTTPembeddedServerBase::startHTTPlisten ( )

◆ stopHTTPlisten()

int HTTPembeddedServerBase::stopHTTPlisten ( const char *  reason)

Stop the HTTP server.

References acceptThreadID, IFLOG_WHEN, listenActive, LOG_ENDLINE, SIGIO, and stopAccepting.

◆ waitForHTTPstop()

int HTTPembeddedServerBase::waitForHTTPstop ( )

Wait for server to cease operations.

References acceptThreadID.

Member Data Documentation

◆ acceptThreadID

pthread_t HTTPembeddedServerBase::acceptThreadID
protected

◆ bufferSize

uint32_t HTTPembeddedServerBase::bufferSize

◆ listenActive

bool HTTPembeddedServerBase::listenActive

◆ listenDescriptor

OS_SOCKET_TYPE HTTPembeddedServerBase::listenDescriptor

◆ listenPort

uint16_t HTTPembeddedServerBase::listenPort

◆ maxHTTPeventLength

uint16_t HTTPembeddedServerBase::maxHTTPeventLength

◆ serverName

char HTTPembeddedServerBase::serverName[64]
protected

◆ stopAccepting

bool HTTPembeddedServerBase::stopAccepting

◆ userData

void* HTTPembeddedServerBase::userData

The documentation for this class was generated from the following files:
Generated: Tue Jul 28 2020 16:03:27
Support Information