Async 1.5.0
Public Member Functions | Protected Member Functions | List of all members
Async::TcpServerBase Class Referenceabstract

The base class for creating a TCP server. More...

#include <AsyncTcpServerBase.h>

Inheritance diagram for Async::TcpServerBase:
Async::TcpServer< ConT >

Public Member Functions

 TcpServerBase (const std::string &port_str, const Async::IpAddress &bind_ip)
 Default constuctor.
 
virtual ~TcpServerBase (void)
 Destructor.
 
int numberOfClients (void)
 Get the number of clients that is connected to the server.
 
TcpConnectiongetClient (unsigned int index)
 Get the client object pointer from the server.
 
int writeAll (const void *buf, int count)
 Write data to all connected clients.
 
int writeOnly (TcpConnection *con, const void *buf, int count)
 Send data only to the given client.
 
int writeExcept (TcpConnection *con, const void *buf, int count)
 Send data to all connected clients except the given client.
 

Protected Member Functions

virtual void createConnection (int sock, const IpAddress &remote_addr, uint16_t remote_port)=0
 
void addConnection (TcpConnection *con)
 
void removeConnection (TcpConnection *con)
 

Detailed Description

The base class for creating a TCP server.

Author
Tobias Blomberg
Date
2003-12-07

Definition at line 112 of file AsyncTcpServerBase.h.

Constructor & Destructor Documentation

◆ TcpServerBase()

Async::TcpServerBase::TcpServerBase ( const std::string &  port_str,
const Async::IpAddress bind_ip 
)

Default constuctor.

Parameters
port_strA port number or service name to listen to
bind_ipThe IP to bind the server to

◆ ~TcpServerBase()

virtual Async::TcpServerBase::~TcpServerBase ( void  )
virtual

Destructor.

Member Function Documentation

◆ addConnection()

void Async::TcpServerBase::addConnection ( TcpConnection con)
protected

◆ createConnection()

virtual void Async::TcpServerBase::createConnection ( int  sock,
const IpAddress remote_addr,
uint16_t  remote_port 
)
protectedpure virtual

Implemented in Async::TcpServer< ConT >.

◆ getClient()

TcpConnection * Async::TcpServerBase::getClient ( unsigned int  index)

Get the client object pointer from the server.

Parameters
indexThe wanted client by number 0 - numberOfClients()-1
Returns
The TcpConnection pointer to the client (zero if not found)

Referenced by Async::TcpServer< ConT >::getClient().

◆ numberOfClients()

int Async::TcpServerBase::numberOfClients ( void  )

Get the number of clients that is connected to the server.

Returns
The number of connected clients
Examples
AsyncFramedTcpServer_demo.cpp, and AsyncTcpServer_demo.cpp.

◆ removeConnection()

void Async::TcpServerBase::removeConnection ( TcpConnection con)
protected

◆ writeAll()

int Async::TcpServerBase::writeAll ( const void *  buf,
int  count 
)

Write data to all connected clients.

Parameters
bufThe data buffer
countThe number of bytes in the data buffer
Returns
The number of bytes sent
Examples
AsyncTcpServer_demo.cpp.

◆ writeExcept()

int Async::TcpServerBase::writeExcept ( TcpConnection con,
const void *  buf,
int  count 
)

Send data to all connected clients except the given client.

Parameters
conThe TcpConnection object not to send to
bufThe data buffer
countThe number of bytes in the data buffer
Returns
The number of bytes sent
Examples
AsyncTcpServer_demo.cpp.

◆ writeOnly()

int Async::TcpServerBase::writeOnly ( TcpConnection con,
const void *  buf,
int  count 
)

Send data only to the given client.

Parameters
conThe TcpConnection object to send to
bufThe data buffer
countThe number of bytes in data buffer
Returns
The number of bytes sent
Examples
AsyncTcpServer_demo.cpp.

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