TcpClient.h
Go to the documentation of this file.
24 using TcpClientEventDelegate = Delegate<void(TcpClient& client, TcpConnectionEvent sourceEvent)>;
53 TcpClient(tcp_pcb* clientTcp, TcpClientDataDelegate clientReceive, TcpClientCompleteDelegate onCompleted)
54 : TcpConnection(clientTcp, true), state(eTCS_Connected), completed(onCompleted), receive(clientReceive)
55 {
A class to make it easier to handle and pass around IP addresses.
Definition: IpAddress.h:45
const char * c_str() const
Get a constant (un-modifiable) pointer to String content.
Definition: WString.h:616
size_t length(void) const
Obtain the String length in characters, excluding NUL terminator.
Definition: WString.h:243
Definition: TcpClient.h:46
virtual void onFinished(TcpClientState finishState)
void pushAsyncPart()
void onError(err_t err) override
TcpClient(TcpClientCompleteDelegate onCompleted, TcpClientDataDelegate onReceive=nullptr)
Definition: TcpClient.h:66
void onClosed() override
Gets called when there is/was a tcp connection, the latter does not have to be established,...
void close() override
err_t onSent(uint16_t len) override
bool send(IDataSourceStream *source, bool forceCloseAfterSent=false)
Sends data stream.
bool send(const char *data, uint16_t len, bool forceCloseAfterSent=false)
void setReceiveDelegate(TcpClientDataDelegate receiveCb=nullptr)
Set or clear the callback for received data.
Definition: TcpClient.h:89
bool sendString(const String &data, bool forceCloseAfterSent=false)
Definition: TcpClient.h:104
err_t onConnected(err_t err) override
void commit()
Tries to send the pending data immediately.
Definition: TcpClient.h:144
void freeStreams()
err_t onReceive(pbuf *buf) override
bool connect(const String &server, int port, bool useSsl=false) override
TcpClient(TcpClientCompleteDelegate onCompleted, TcpClientEventDelegate onReadyToSend, TcpClientDataDelegate onReceive=nullptr)
Definition: TcpClient.h:59
void setCloseAfterSent(bool ignoreIncomingData=false)
Definition: TcpClient.h:135
TcpClient(tcp_pcb *clientTcp, TcpClientDataDelegate clientReceive, TcpClientCompleteDelegate onCompleted)
Definition: TcpClient.h:53
bool connect(IpAddress addr, uint16_t port, bool useSsl=false) override
void onReadyToSendData(TcpConnectionEvent sourceEvent) override
void setCompleteDelegate(TcpClientCompleteDelegate completeCb=nullptr)
Set or clear the callback for connection close.
Definition: TcpClient.h:97
IDataSourceStream * stream
The currently active stream being sent.
Definition: TcpClient.h:165
Definition: TcpConnection.h:40
uint16_t timeOut
By default a TCP connection does not have a time out.
Definition: TcpConnection.h:224
void flush()
Server server