FIX::HttpServer Class Reference

Basic HTTP Server. More...

`#include <HttpServer.h>`

Inheritance diagram for FIX::HttpServer:
[legend]
Collaboration diagram for FIX::HttpServer:
[legend]

## Public Member Functions

| HttpServer (const SessionSettings &) throw ( ConfigError )
void | start () throw ( ConfigError, RuntimeError )
void | stop ()
Public Member Functions inherited from FIX::SocketServer::Strategy
virtual | ~Strategy ()

## Static Public Member Functions

static void | startGlobal (const SessionSettings &) throw ( ConfigError, RuntimeError )
static void | stopGlobal ()

## Private Member Functions

void | onConfigure (const SessionSettings &) throw ( ConfigError )
void | onInitialize (const SessionSettings &) throw ( RuntimeError )
void | onStart ()
bool | onPoll ()
void | onStop ()
void | onConnect (SocketServer &, int, int)
void | onWrite (SocketServer &, int)
bool | onData (SocketServer &, int)
void | onDisconnect (SocketServer &, int)
void | onError (SocketServer &)
void | onTimeout (SocketServer &)

## Static Private Member Functions

static THREAD_PROC | startThread (void *p)

## Private Attributes

SocketServer * | m_pServer
SessionSettings | m_settings
thread_id | m_threadid
int | m_port
bool | m_stop

## Static Private Attributes

static Mutex | s_mutex
static int | s_count = 0
static HttpServer * | s_pServer = 0

## Detailed Description

Basic HTTP Server.

Definition at line 54 of file HttpServer.h.

## Constructor & Destructor Documentation

## HttpServer()

FIX::HttpServer::HttpServer | ( | const SessionSettings & | settings | ) |
throw | ( | ConfigError
| ) |  |

Definition at line 83 of file HttpServer.cpp.

{

References FIX::IntConvertor::convert().

## Member Function Documentation

## onConfigure()

void FIX::HttpServer::onConfigure | ( | const SessionSettings & | s | ) |
throw | ( | ConfigError
| ) |  |

private

Definition at line 86 of file HttpServer.cpp.

{

## onConnect()

void FIX::HttpServer::onConnect | ( | SocketServer & | server,
|  | int | a,
|  | int | s
| ) |  |

private virtual

Implements FIX::SocketServer::Strategy.

Definition at line 152 of file HttpServer.cpp.

{
}
void HttpServer::onError( SocketServer& ) {}
void HttpServer::onTimeout( SocketServer& )

## onData()

bool FIX::HttpServer::onData | ( | SocketServer & | server,
|  | int | s
| ) |  |

private virtual

Implements FIX::SocketServer::Strategy.

Definition at line 164 of file HttpServer.cpp.

## onDisconnect()

void FIX::HttpServer::onDisconnect | ( | SocketServer & | ,
|  | int | s
| ) |  |

private virtual

Implements FIX::SocketServer::Strategy.

Definition at line 169 of file HttpServer.cpp.

## onError()

void FIX::HttpServer::onError | ( | SocketServer & |  | ) |

private virtual

Implements FIX::SocketServer::Strategy.

Definition at line 173 of file HttpServer.cpp.

## onInitialize()

void FIX::HttpServer::onInitialize | ( | const SessionSettings & | s | ) |
throw | ( | RuntimeError
| ) |  |

private

Definition at line 92 of file HttpServer.cpp.

{
if( m_stop ) return;
m_stop = true;
onStop();

## onPoll()

bool FIX::HttpServer::onPoll | ( |  | ) |

private

Definition at line 139 of file HttpServer.cpp.

{}
m_pServer->getMonitor().drop( s );
}
void HttpServer::onWrite( SocketServer& server, int s )
{
}

## onStart()

void FIX::HttpServer::onStart | ( |  | ) |

private

Definition at line 127 of file HttpServer.cpp.

{
}
void HttpServer::onConnect( SocketServer& server, int a, int s )
{
if ( !socket_isValid( s ) ) return;

## onStop()

void FIX::HttpServer::onStop | ( |  | ) |

private

Definition at line 148 of file HttpServer.cpp.

{
return true;
}

## onTimeout()

void FIX::HttpServer::onTimeout | ( | SocketServer & |  | ) |

private virtual

Reimplemented from FIX::SocketServer::Strategy.

Definition at line 175 of file HttpServer.cpp.

## onWrite()

void FIX::HttpServer::onWrite | ( | SocketServer & | server,
|  | int | s
| ) |  |

private virtual

Implements FIX::SocketServer::Strategy.

Definition at line 160 of file HttpServer.cpp.

{

## start()

void FIX::HttpServer::start | ( |  | ) |
throw | ( | ConfigError,
|  | RuntimeError
| ) |  |

Definition at line 106 of file HttpServer.cpp.

{
while ( !m_stop && m_pServer && m_pServer->block( *this ) ) {}
if( !m_pServer )

## startGlobal()

void FIX::HttpServer::startGlobal | ( | const SessionSettings & | s | ) |
throw | ( | ConfigError,
|  | RuntimeError
| ) |  |

static

Definition at line 54 of file HttpServer.cpp.

{
Locker l( s_mutex );
s_count -= 1;
if( !s_count && s_pServer )
{
s_pServer->stop();
delete s_pServer;
s_pServer = 0;
}
}
HttpServer::HttpServer( const SessionSettings& settings ) throw( ConfigError )
: m_pServer( 0 ), m_settings( settings ), m_threadid( 0 ), m_port( 0 ), m_stop( false ) {}

References s_count, s_mutex, s_pServer, and stop().

## startThread()

THREAD_PROC FIX::HttpServer::startThread | ( | void * | p | ) |

static private

Definition at line 179 of file HttpServer.cpp.

## stop()

void FIX::HttpServer::stop | ( |  | ) |

Definition at line 116 of file HttpServer.cpp.

{
if( !m_pServer || m_stop )
return false;

Referenced by startGlobal().

## stopGlobal()

void FIX::HttpServer::stopGlobal | ( |  | ) |

static

Definition at line 70 of file HttpServer.cpp.

{
m_port = s.get().getInt( HTTP_ACCEPT_PORT );
}
void HttpServer::onInitialize( const SessionSettings& s )
throw ( RuntimeError )
{
try
{
m_pServer = new SocketServer( 1 );
m_pServer->add( m_port, true, false, 0, 0 );

References FIX::HTTP_ACCEPT_PORT.

## Member Data Documentation

## m_port

int FIX::HttpServer::m_port

private

Definition at line 102 of file HttpServer.h.

## m_pServer

SocketServer* FIX::HttpServer::m_pServer

private

Definition at line 99 of file HttpServer.h.

## m_settings

SessionSettings FIX::HttpServer::m_settings

private

Definition at line 100 of file HttpServer.h.

## m_stop

bool FIX::HttpServer::m_stop

private

Definition at line 103 of file HttpServer.h.

## m_threadid

thread_id FIX::HttpServer::m_threadid

private

Definition at line 101 of file HttpServer.h.

## s_count

int FIX::HttpServer::s_count = 0

static private

Definition at line 106 of file HttpServer.h.

Referenced by startGlobal().

## s_mutex

Mutex FIX::HttpServer::s_mutex

static private

Definition at line 105 of file HttpServer.h.

Referenced by startGlobal().

## s_pServer

HttpServer * FIX::HttpServer::s_pServer = 0

static private

Definition at line 107 of file HttpServer.h.

Referenced by startGlobal().

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

- HttpServer.h
- HttpServer.cpp

FIX::HttpServer::m_stop
bool m_stop
Definition: HttpServer.h:103
FIX::HttpServer::onWrite
void onWrite(SocketServer &, int)
Definition: HttpServer.cpp:160
FIX::HttpServer::onInitialize
void onInitialize(const SessionSettings &)
Definition: HttpServer.cpp:92
FIX::SocketServer::block
bool block(Strategy &strategy, bool poll=0, double timeout=0.0)
Definition: SocketServer.cpp:165
FIX::HttpServer::s_pServer
static HttpServer * s_pServer
Definition: HttpServer.h:107
FIX::HttpServer::onConnect
void onConnect(SocketServer &, int, int)
Definition: HttpServer.cpp:152
FIX::HttpServer::m_settings
SessionSettings m_settings
Definition: HttpServer.h:100
FIX::socket_isValid
bool socket_isValid(int socket)
Definition: Utility.cpp:294
FIX::SocketServer::getMonitor
SocketMonitor & getMonitor()
Definition: SocketServer.h:87
FIX::HttpServer::s_count
static int s_count
Definition: HttpServer.h:106
FIX::HttpServer::onError
void onError(SocketServer &)
Definition: HttpServer.cpp:173
FIX::HttpServer::m_port
int m_port
Definition: HttpServer.h:102
FIX::HttpServer::HttpServer
HttpServer(const SessionSettings &)
Definition: HttpServer.cpp:83
FIX::SocketMonitor::drop
bool drop(int socket)
Definition: SocketMonitor.cpp:115
FIX::HttpServer::onTimeout
void onTimeout(SocketServer &)
Definition: HttpServer.cpp:175
FIX::HttpServer::s_mutex
static Mutex s_mutex
Definition: HttpServer.h:105
FIX::HttpServer::m_threadid
thread_id m_threadid
Definition: HttpServer.h:101
FIX::HttpServer::onStop
void onStop()
Definition: HttpServer.cpp:148
FIX::HttpServer::m_pServer
SocketServer * m_pServer
Definition: HttpServer.h:99
FIX::HTTP_ACCEPT_PORT
const char HTTP_ACCEPT_PORT[]
Definition: SessionSettings.h:148
FIX::SocketServer::add
int add(int port, bool reuse=false, bool noDelay=false, int sendBufSize=0, int rcvBufSize=0)
Definition: SocketServer.cpp:114
FIX::HttpServer::stop
void stop()
Definition: HttpServer.cpp:116