TcpClient.h
Go to the documentation of this file.
25 typedef Delegate<void(TcpClient& client, TcpConnectionEvent sourceEvent)> TcpClientEventDelegate;
54 TcpClient(tcp_pcb* clientTcp, TcpClientDataDelegate clientReceive, TcpClientCompleteDelegate onCompleted)
55 : TcpConnection(clientTcp, true), state(eTCS_Connected), completed(onCompleted), receive(clientReceive)
void setReceiveDelegate(TcpClientDataDelegate receiveCb=nullptr)
Set or clear the callback for received data.
Definition: TcpClient.h:90
A class to make it easier to handle and pass around IP addresses.
Definition: IpAddress.h:43
uint16_t timeOut
By default a TCP connection does not have a time out.
Definition: TcpConnection.h:199
Definition: TcpClient.h:30
void pushAsyncPart()
Definition: TcpClient.h:31
TcpClient(tcp_pcb *clientTcp, TcpClientDataDelegate clientReceive, TcpClientCompleteDelegate onCompleted)
Definition: TcpClient.h:54
const char * c_str() const
Get a constant (un-modifiable) pointer to String content.
Definition: WString.h:600
void setCompleteDelegate(TcpClientCompleteDelegate completeCb=nullptr)
Set or clear the callback for connection close.
Definition: TcpClient.h:98
void close() override
void setBuffer(ReadWriteStream *stream)
Delegate< void(TcpClient &client, TcpConnectionEvent sourceEvent)> TcpClientEventDelegate
Definition: TcpClient.h:23
Definition: TcpConnection.h:39
void onReadyToSendData(TcpConnectionEvent sourceEvent) override
Definition: TcpClient.h:46
Definition: TcpClient.h:39
bool send(const char *data, uint16_t len, bool forceCloseAfterSent=false)
size_t length(void) const
Obtain the String length in characters, excluding NUL terminator.
Definition: WString.h:228
bool sendString(const String &data, bool forceCloseAfterSent=false)
Definition: TcpClient.h:105
Delegate< bool(TcpClient &client, char *data, int size)> TcpClientDataDelegate
Definition: TcpClient.h:27
err_t onReceive(pbuf *buf) override
err_t onSent(uint16_t len) override
TcpClient(TcpClientCompleteDelegate onCompleted, TcpClientDataDelegate onReceive=nullptr)
Definition: TcpClient.h:67
Definition: TcpClient.h:40
virtual void onFinished(TcpClientState finishState)
Definition: TcpClient.h:38
void onError(err_t err) override
Delegate< void(TcpClient &client, bool successful)> TcpClientCompleteDelegate
Definition: TcpClient.h:26
ReadWriteStream * buffer
Used internally to buffer arbitrary data via send() methods.
Definition: TcpClient.h:144
Definition: TcpClient.h:32
void setCloseAfterSent(bool ignoreIncomingData=false)
Definition: TcpClient.h:124
void freeStreams()
Definition: TcpClient.h:33
IDataSourceStream * stream
The currently active stream being sent.
Definition: TcpClient.h:145
Definition: TcpClient.h:34
bool connect(const String &server, int port, bool useSsl=false) override
err_t onConnected(err_t err) override
TcpClient(TcpClientCompleteDelegate onCompleted, TcpClientEventDelegate onReadyToSend, TcpClientDataDelegate onReceive=nullptr)
Definition: TcpClient.h:60