TcpClient.h
Go to the documentation of this file.
25 using TcpClientEventDelegate = Delegate<void(TcpClient& client, TcpConnectionEvent sourceEvent)>;
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:220
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:641
void setCompleteDelegate(TcpClientCompleteDelegate completeCb=nullptr)
Set or clear the callback for connection close.
Definition: TcpClient.h:98
void close() override
void setBuffer(ReadWriteStream *stream)
Definition: TcpConnection.h:29
Definition: TcpConnection.h:39
void onReadyToSendData(TcpConnectionEvent sourceEvent) override
Definition: TcpClient.h:46
Definition: TcpClient.h:39
Server server
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:237
bool sendString(const String &data, bool forceCloseAfterSent=false)
Definition: TcpClient.h:105
void onClosed() override
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.
err_t onReceive(pbuf *buf) override
void commit()
Tries to send the pending data immediately.
Definition: TcpClient.h:133
void flush()
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
ReadWriteStream * buffer
Used internally to buffer arbitrary data via send() methods.
Definition: TcpClient.h:156
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:157
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