sptk2 logo
SPTK Home Page
Public Member Functions | List of all members
sptk::TCPServerConnection Class Reference

Abstract TCP server connection thread. More...

#include <TCPServerConnection.h>

Inheritance diagram for sptk::TCPServerConnection:
sptk::ServerConnection sptk::Runable

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={})
 
TCPSocketsocket () const
 
TCPServerserver () 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
 

Detailed Description

Abstract TCP server connection thread.

Application derives concrete TCP server connections based on this class, to use with CTCPServer as connection template

Constructor & Destructor Documentation

◆ TCPServerConnection()

sptk::TCPServerConnection::TCPServerConnection ( TCPServer server,
SOCKET  connectionSocket,
const sockaddr_in *  connectionAddress,
const ServerConnection::Function &  connectionFunction 
)
inlineexplicit

Constructor.

Parameters
serverTCP server
connectionSocketAlready accepted by accept() function incoming connection socket
connectionAddressIncoming connection address
connectionFunctionConnection function executed for each new client connection to server

References sptk::BaseSocket::attach(), sptk::ServerConnection::setSocket(), and sptk::ServerConnection::socket().

Member Function Documentation

◆ terminate()

void sptk::TCPServerConnection::terminate ( )
inlineoverridevirtual

Terminate connection thread

Reimplemented from sptk::Runable.

References sptk::TCPSocket::close(), sptk::ServerConnection::socket(), and sptk::Runable::terminate().


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

Fri Oct 14 2022 09:58:46: SPTK 5.4.1