#include <TcpServer.h>

Inheritance diagram for TcpServer:
Collaboration diagram for TcpServer:

Public Member Functions

 TcpServer ()
 
 TcpServer (TcpClientConnectDelegate onClientHandler, TcpClientDataDelegate clientReceiveDataHandler, TcpClientCompleteDelegate clientCompleteHandler)
 
 TcpServer (TcpClientDataDelegate clientReceiveDataHandler, TcpClientCompleteDelegate clientCompleteHandler)
 
 TcpServer (TcpClientDataDelegate clientReceiveDataHandler)
 
void setClientReceiveHandler (TcpClientDataDelegate clientReceiveDataHandler)
 
 ~TcpServer ()
 
virtual bool listen (int port, bool useSsl=false)
 
void setKeepAlive (uint16_t seconds)
 
void shutdown ()
 
const Vector< TcpConnection * > & getConnections () const
 
- Public Member Functions inherited from TcpConnection
 TcpConnection (bool autoDestruct)
 
 TcpConnection (tcp_pcb *connection, bool autoDestruct)
 
virtual ~TcpConnection ()
 
virtual bool connect (const String &server, int port, bool useSsl=false)
 
virtual bool connect (IpAddress addr, uint16_t port, bool useSsl=false)
 
virtual void close ()
 
void setAutoSelfDestruct (bool state)
 
int writeString (const char *data, uint8_t apiflags=TCP_WRITE_FLAG_COPY)
 Writes string data directly to the TCP buffer. More...
 
int writeString (const String &data, uint8_t apiflags=TCP_WRITE_FLAG_COPY)
 Writes string data directly to the TCP buffer. More...
 
virtual int write (const char *data, int len, uint8_t apiflags=TCP_WRITE_FLAG_COPY)
 Base write operation. More...
 
int write (IDataSourceStream *stream)
 Writes stream data directly to the TCP buffer. More...
 
uint16_t getAvailableWriteSize ()
 
void flush ()
 
void setTimeOut (uint16_t waitTimeOut)
 
IpAddress getRemoteIp () const
 
uint16_t getRemotePort () const
 
void setDestroyedDelegate (TcpConnectionDestroyedDelegate destroyedDelegate)
 Sets a callback to be called when the object instance is destroyed. More...
 
void setSslInitHandler (Ssl::Session::InitDelegate handler)
 Set the SSL session initialisation callback. More...
 
bool setSslConnection (Ssl::Connection *connection)
 
Ssl::SessiongetSsl ()
 Get a pointer to the current SSL session object. More...
 
- Public Member Functions inherited from IpConnection
bool joinMulticastGroup (IpAddress localIp, IpAddress multicastIp)
 Uses IGMP to add a local network interface to multicast group. More...
 
bool joinMulticastGroup (IpAddress multicastIp)
 Uses IGMP to add all local network interfaces to multicast group. More...
 
bool leaveMulticastGroup (IpAddress localIp, IpAddress multicastIp)
 Uses IGMP to remove a local network interface from multicast group. More...
 
bool leaveMulticastGroup (IpAddress multicastIp)
 Uses IGMP to remove all local network interfaces from multicast group. More...
 

Public Attributes

uint16_t activeClients = 0
 

Protected Member Functions

virtual TcpConnectioncreateClient (tcp_pcb *clientTcp)
 
virtual err_t onAccept (tcp_pcb *clientTcp, err_t err)
 
virtual void onClient (TcpClient *client)
 
virtual bool onClientReceive (TcpClient &client, char *data, int size)
 
virtual void onClientComplete (TcpClient &client, bool successful)
 
virtual void onClientDestroy (TcpConnection &connection)
 
- Protected Member Functions inherited from TcpConnection
void initialize (tcp_pcb *pcb)
 
bool internalConnect (IpAddress addr, uint16_t port)
 
bool sslCreateSession ()
 
virtual void sslInitSession (Ssl::Session &session)
 Override in inherited classes to perform custom session initialisation. More...
 
virtual err_t onConnected (err_t err)
 
virtual err_t onReceive (pbuf *buf)
 
virtual err_t onSent (uint16_t len)
 
virtual err_t onPoll ()
 
virtual void onError (err_t err)
 
virtual void onReadyToSendData (TcpConnectionEvent sourceEvent)
 
virtual void onClosed ()
 Gets called when there is/was a tcp connection, the latter does not have to be established, that is closed due to error or normal disconnect. More...
 
void trySend (TcpConnectionEvent event)
 
err_t internalOnConnected (err_t err)
 
err_t internalOnReceive (pbuf *p, err_t err)
 
err_t internalOnSent (uint16_t len)
 
err_t internalOnPoll ()
 
void internalOnError (err_t err)
 
void internalOnDnsResponse (const char *name, LWIP_IP_ADDR_T *ipaddr, int port)
 

Protected Attributes

size_t minHeapSize = 16384
 
uint16_t maxConnections = 0
 By default, don't limit connection count. More...
 
bool active = true
 
Vector< TcpConnection * > connections
 
- Protected Attributes inherited from TcpConnection
tcp_pcb * tcp = nullptr
 
uint16_t sleep = 0
 
uint16_t timeOut = USHRT_MAX
 By default a TCP connection does not have a time out. More...
 
bool canSend = true
 
bool autoSelfDestruct = true
 
Ssl::Sessionssl = nullptr
 
Ssl::Session::InitDelegate sslInit
 
bool useSsl = false
 

Constructor & Destructor Documentation

◆ TcpServer() [1/4]

TcpServer::TcpServer ( )
inline

◆ TcpServer() [2/4]

TcpServer::TcpServer ( TcpClientConnectDelegate  onClientHandler,
TcpClientDataDelegate  clientReceiveDataHandler,
TcpClientCompleteDelegate  clientCompleteHandler 
)
inline

◆ TcpServer() [3/4]

TcpServer::TcpServer ( TcpClientDataDelegate  clientReceiveDataHandler,
TcpClientCompleteDelegate  clientCompleteHandler 
)
inline

◆ TcpServer() [4/4]

TcpServer::TcpServer ( TcpClientDataDelegate  clientReceiveDataHandler)
inline

◆ ~TcpServer()

TcpServer::~TcpServer ( )
inline

Member Function Documentation

◆ createClient()

virtual TcpConnection* TcpServer::createClient ( tcp_pcb *  clientTcp)
protectedvirtual

Reimplemented in HttpServer, and CustomFtpServer.

◆ getConnections()

const Vector<TcpConnection*>& TcpServer::getConnections ( ) const
inline

◆ listen()

virtual bool TcpServer::listen ( int  port,
bool  useSsl = false 
)
virtual

◆ onAccept()

virtual err_t TcpServer::onAccept ( tcp_pcb *  clientTcp,
err_t  err 
)
protectedvirtual

◆ onClient()

virtual void TcpServer::onClient ( TcpClient client)
protectedvirtual

◆ onClientComplete()

virtual void TcpServer::onClientComplete ( TcpClient client,
bool  successful 
)
protectedvirtual

◆ onClientDestroy()

virtual void TcpServer::onClientDestroy ( TcpConnection connection)
protectedvirtual

◆ onClientReceive()

virtual bool TcpServer::onClientReceive ( TcpClient client,
char *  data,
int  size 
)
protectedvirtual

◆ setClientReceiveHandler()

void TcpServer::setClientReceiveHandler ( TcpClientDataDelegate  clientReceiveDataHandler)
inline

◆ setKeepAlive()

void TcpServer::setKeepAlive ( uint16_t  seconds)

◆ shutdown()

void TcpServer::shutdown ( )

Member Data Documentation

◆ active

bool TcpServer::active = true
protected

◆ activeClients

uint16_t TcpServer::activeClients = 0

◆ connections

Vector<TcpConnection*> TcpServer::connections
protected

◆ maxConnections

uint16_t TcpServer::maxConnections = 0
protected

By default, don't limit connection count.

◆ minHeapSize

size_t TcpServer::minHeapSize = 16384
protected

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