TCP: Transmission Control Protocol¶
https://en.m.wikipedia.org/wiki/Transmission_Control_Protocol
Connection API¶
-
enum
tcp
::
TcpConnectionEvent
¶ Values:
-
eTCE_Connected
= 0¶ Occurs after connection establishment.
-
eTCE_Received
¶ Occurs on data receive.
-
eTCE_Sent
¶
-
eTCE_Poll
¶
-
-
using
TcpConnectionDestroyedDelegate
= Delegate<void(TcpConnection&)>¶
-
NETWORK_DEBUG
¶
-
NETWORK_SEND_BUFFER_SIZE
¶
-
class
TcpConnection
: public IpConnection¶ - #include <TcpConnection.h>
Subclassed by FtpDataStream, FtpServerConnection, TcpClient, TcpServer
Public Functions
-
int
writeString
(const char *data, uint8_t apiflags = TCP_WRITE_FLAG_COPY)¶ Writes string data directly to the TCP buffer.
- Parameters
data
: null terminated stringapiflags
: TCP_WRITE_FLAG_COPY, TCP_WRITE_FLAG_MORE
- Return Value
int
: negative on error, 0 when retry is needed or possitive on success
-
int
writeString
(const String &data, uint8_t apiflags = TCP_WRITE_FLAG_COPY)¶ Writes string data directly to the TCP buffer.
- Parameters
data
:apiflags
: TCP_WRITE_FLAG_COPY, TCP_WRITE_FLAG_MORE
- Return Value
int
: negative on error, 0 when retry is needed or possitive on success
-
virtual int
write
(const char *data, int len, uint8_t apiflags = TCP_WRITE_FLAG_COPY)¶ Base write operation.
- Parameters
data
:len
:apiflags
: TCP_WRITE_FLAG_COPY, TCP_WRITE_FLAG_MORE
- Return Value
int
: negative on error, 0 when retry is needed or possitive on success
-
int
write
(IDataSourceStream *stream)¶ Writes stream data directly to the TCP buffer.
- Parameters
stream
:apiflags
: TCP_WRITE_FLAG_COPY, TCP_WRITE_FLAG_MORE
- Return Value
int
: negative on error, 0 when retry is needed or possitive on success
-
void
setDestroyedDelegate
(TcpConnectionDestroyedDelegate destroyedDelegate)¶ Sets a callback to be called when the object instance is destroyed.
- Parameters
destroyedDelegate
:
-
int
Client API¶
-
enum
tcpclient
::
TcpClientState
¶ Values:
-
eTCS_Ready
¶
-
eTCS_Connecting
¶
-
eTCS_Connected
¶
-
eTCS_Successful
¶
-
eTCS_Failed
¶
-
-
enum
tcpclient
::
TcpClientCloseAfterSentState
¶ Values:
-
eTCCASS_None
¶
-
eTCCASS_AfterSent
¶
-
eTCCASS_AfterSent_Ignore_Received
¶
-
-
TCP_CLIENT_TIMEOUT
¶
-
class
TcpClient
: public TcpConnection¶ - #include <TcpClient.h>
Subclassed by HttpConnection, MqttClient, SmtpClient
Public Functions
-
void
setReceiveDelegate
(TcpClientDataDelegate receiveCb = nullptr)¶ Set or clear the callback for received data.
- Parameters
receiveCb
: callback delegate or nullptr
-
void
setCompleteDelegate
(TcpClientCompleteDelegate completeCb = nullptr)¶ Set or clear the callback for connection close.
- Parameters
completeCb
: callback delegate or nullptr
-
void
setCloseAfterSent
(bool ignoreIncomingData = false)¶ Schedules the connection to get closed after the data is sent
- Parameters
ignoreIncomingData
: when that flag is set the connection will start ignoring incoming data.
-
void
Server API¶
-
TCP_SERVER_TIMEOUT
¶
-
class
TcpServer
: public TcpConnection¶ - #include <TcpServer.h>
Subclassed by CustomFtpServer, HttpServer, TelnetServer