dodo
0.0.1
A C++ library to create containerized Linux services
|
Go to the documentation of this file.
23 #ifndef network_tcpserver_hpp
24 #define network_tcpserver_hpp
@ ssReadSocket
The TCPServer is about to invoke readSocket(BaseSocket*).
TCPServer(TCPListener &listener)
Construct a TCPServer for the TCPListener.
double getIdleSeconds()
Get the number of secodns the TCPServer has been idle.
@ ssShutdown
The TCPServer is about to invoke shutdown(BaseSocket*).
virtual bool handShake(network::BaseSocket *socket, ssize_t &received, ssize_t &sent)=0
Override to perform a protocol handshake.
bool request_stop_
If true, the TCPServer should stop.
@ ssAwoken
The TCPServer has woken up from a wait either due to an event or the wait timing out.
@ ssShutdownDone
ssShutdown completed.
@ ssHandshakeDone
ssHandshake completed.
bool has_stopped_
If true, the TCPServer has stopped.
@ ssHandshake
The TCPServer is about to invoke handShake(BaseSocket*).
virtual void run()
Run the TCPServer thread.
A C++ platform interface to lean Linux services tailored for containerized deployment.
struct timeval last_active_
Time of last request handling.
ServerState
The possible states of a TCPServer.
bool isBusy() const
Return true if the TCPServer is busy.
@ ssReleaseWork
The TCPServer is releasing the request.
@ ssWait
The TCPServer has entered waiting for activity or wait timeout.
bool getRequestStop() const
Return true if the TCPServer was requested to stop.
bool busy_
If true, the TCPServer is processing a request.
virtual TCPServer * addServer()=0
Spawn a new TCPServer.
virtual TCPConnectionData * newConnectionData() const
Return a new TCPConnectionData pointer or override to return a descendant of TCPConnectionData.
Used in conjunction with TCPListener to implement high speed, multithreaded TCP services.
@ ssReadSocketDone
ssReadSocket completed.
@ ssReleaseWorkDone
ssReleaseWork completed.
virtual common::SystemError readSocket(TCPListener::SocketWork &work, ssize_t &sent)=0
Override to perform a request-response cycle.
ServerState getState() const
Return the current ServerState.
ServerState state_
State of the TCPServer.
Class to track a connection.
Linux system error primitive to provide a consistent interface to Linux error codes.
The TCPListener listens, accepts connections and generates socket events to produce TCP work to a poo...
virtual void shutDown(network::BaseSocket *socket)=0
Override to perform a shutdown.
void requestStop()
Set the request_stop_ flag, this call returns immediately, stopping will follow.
TCPListener & listener_
The TCPListener the TCPServer is working for.
Interface to and common implementation of concrete sockets (Socket, TLSSocket).
bool hasStopped() const
Return true if the TCPServer has stopped working.