#include <ServerConnection.h>
Public Types | |
enum class | Type { TCP , SSL } |
using | Function = std::function< void(const Runable &task, TCPSocket &socket, const String &address)> |
Public Member Functions | |
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 |
Protected Member Functions | |
void | setSocket (const STCPSocket &socket) |
void | parseAddress (const sockaddr_in *connectionAddress) |
void | run () override |
virtual void | run ()=0 |
Friends | |
class | TCPServer |
Abstract TCP or SSL server connection thread
Used a base class for CTCPServerConnection and COpenSSLServerConnection
sptk::ServerConnection::ServerConnection | ( | TCPServer & | server, |
SOCKET | connectionSocket, | ||
Type | type, | ||
const sockaddr_in * | connectionAddress, | ||
const String & | taskName, | ||
const ServerConnection::Function & | connectionFunction = {} |
||
) |
Constructor
server | Server that created this connection |
connectionSocket | Already accepted by accept() function incoming connection socket |
taskName | Task name |
connectionFunction | Connection function processing this connection |
|
inline |
Get incoming connection address
|
inlineoverrideprotectedvirtual |
Method that is executed by worker thread
Should be overwritten by derived class.
Implements sptk::Runable.
Reimplemented in sptk::WSConnection.
|
inline |
Get connection serial number
TCPServer & sptk::ServerConnection::server | ( | ) | const |
|
protected |
Assign new socket
socket | Socket to assign |
Referenced by sptk::SSLServerConnection::SSLServerConnection(), and sptk::TCPServerConnection::TCPServerConnection().
TCPSocket & sptk::ServerConnection::socket | ( | ) | const |
Access to internal socket for derived classes
Referenced by sptk::TCPServerConnection::TCPServerConnection(), and sptk::TCPServerConnection::terminate().