#include <INET.hh>
Server request handler. Should be sub-classed and the virtual member function on_request() should be implemented to receive client requests and send responses.
Definition at line 184 of file INET.hh.
Default server constructor. Must call begin() to initiate with socket. Associate with given io-stream. The socket will be bound as the io-stream device.
- Parameters
-
[in] | ios | associated io-stream. |
Definition at line 192 of file INET.hh.
bool INET::Server::begin |
( |
Socket * |
sock | ) |
|
|
virtual |
Start server with given socket. Initiates socket for incoming connection-oriented requests (TCP/listen). Returns true if successful otherwise false.
- Parameters
-
- Returns
- bool.
Definition at line 34 of file INET_Server.cpp.
Get client address, network address and port.
- Parameters
-
[out] | addr | network address. |
Definition at line 26 of file INET_Server.cpp.
bool INET::Server::end |
( |
| ) |
|
|
virtual |
Stop server and close socket. Returns true if successful otherwise false.
- Returns
- bool.
Definition at line 92 of file INET_Server.cpp.
virtual bool INET::Server::on_accept |
( |
IOStream & |
ios | ) |
|
|
inlinevirtual |
Application extension; Called when a client connect has been accepted. Return true if application accepts otherwise false.
- Parameters
-
[in] | ios | iostream for response. |
- Returns
- bool.
Definition at line 248 of file INET.hh.
virtual void INET::Server::on_connect |
( |
IOStream & |
ios | ) |
|
|
inlinevirtual |
Application extension; Called when a client connect has been accepted.
- Parameters
-
[in] | ios | iostream for response. |
Definition at line 260 of file INET.hh.
virtual void INET::Server::on_disconnect |
( |
| ) |
|
|
inlinevirtual |
Application extension; Called when a client disconnects.
Definition at line 277 of file INET.hh.
virtual void INET::Server::on_request |
( |
IOStream & |
ios | ) |
|
|
pure virtual |
Application extension; Should implement the response to the incoming request. Called with there is available data.
- Parameters
-
[in] | ios | iostream for request and response. |
int INET::Server::run |
( |
uint32_t |
ms = 0L | ) |
|
|
virtual |
Run server; service incoming client connect requests or data. Wait for at most given time period. Zero time period will give blocking behavior. Returns zero if successful or negative error code. The error code ETIME is returned on timeout.
- Parameters
-
[in] | ms | timeout period (milli-seconds, default BLOCK(0L)). |
- Returns
- zero or negative error code.
Definition at line 47 of file INET_Server.cpp.
Socket* INET::Server::socket |
( |
| ) |
|
|
inline |
Get server socket.
- Returns
- socket.
Definition at line 201 of file INET.hh.
bool INET::Server::m_connected |
|
protected |
State variable; listening/disconnect(false), connected(true).
Definition at line 284 of file INET.hh.
Associated io-stream
Definition at line 281 of file INET.hh.
The documentation for this class was generated from the following files: