Abstract TCP server connection thread. More...
#include <TCPServerConnection.h>
Public Member Functions | |
TCPServerConnection (TCPServer &server, SOCKET connectionSocket, const sockaddr_in *connectionAddress, const ServerConnection::Function &connectionFunction) | |
Constructor. More... | |
void | terminate () override |
Public Member Functions inherited from sptk::ServerConnection | |
ServerConnection (TCPServer &server, SOCKET connectionSocket, Type type, const sockaddr_in *connectionAddress, const String &taskName, const ServerConnection::Function &connectionFunction={}) | |
TCPSocket & | socket () const |
TCPServer & | server () const |
String | address () const |
size_t | serial () const |
Public Member Functions inherited from sptk::Runable | |
Runable (const String &name) | |
virtual | ~Runable ()=default |
void | execute () |
virtual void | terminate () |
bool | terminated () const |
String | name () const |
Additional Inherited Members | |
Public Types inherited from sptk::ServerConnection | |
enum class | Type { TCP , SSL } |
using | Function = std::function< void(const Runable &task, TCPSocket &socket, const String &address)> |
Protected Member Functions inherited from sptk::ServerConnection | |
void | setSocket (const STCPSocket &socket) |
void | parseAddress (const sockaddr_in *connectionAddress) |
void | run () override |
virtual void | run ()=0 |
Abstract TCP server connection thread.
Application derives concrete TCP server connections based on this class, to use with CTCPServer as connection template
|
inlineexplicit |
Constructor.
server | TCP server |
connectionSocket | Already accepted by accept() function incoming connection socket |
connectionAddress | Incoming connection address |
connectionFunction | Connection function executed for each new client connection to server |
References sptk::BaseSocket::attach(), sptk::ServerConnection::setSocket(), and sptk::ServerConnection::socket().
|
inlineoverridevirtual |
Terminate connection thread
Reimplemented from sptk::Runable.
References sptk::TCPSocket::close(), sptk::ServerConnection::socket(), and sptk::Runable::terminate().