PL::TcpClient class

class TcpClient : public PL::Lockable

TCP client class.

Public Functions

TcpClient(IpV4Address address, uint16_t port)

Creates an IPv4 TCP client.

Parameters:
  • address – IPv4 addres

  • port – port

TcpClient(IpV6Address address, uint16_t port)

Creates an IPv6 TCP client.

Parameters:
  • address – IPv6 addres

  • port – port

virtual esp_err_t Lock(TickType_t timeout = portMAX_DELAY) override

Locks the object.

Parameters:

timeout – timeout in FreeRTOS ticks

Returns:

error code

virtual esp_err_t Unlock() override

Unlocks the object.

Returns:

error code

esp_err_t Connect()

Connects to the server if not already connected.

Returns:

error code

esp_err_t Disconnect()

Disconnects from the server.

Returns:

error code

esp_err_t EnableNagleAlgorithm()

Enables the Nagle’s algorithm.

Returns:

error code

esp_err_t DisableNagleAlgorithm()

Disables the Nagle’s algorithm.

Returns:

error code

bool IsConnected()

Checks if the client is connected.

Returns:

true if the client is connected

TickType_t GetReadTimeout()

Gets the read operation timeout.

Returns:

timeout in FreeRTOS ticks

esp_err_t SetReadTimeout(TickType_t timeout)

Sets the read operation timeout.

Parameters:

timeout – timeout in FreeRTOS ticks

Returns:

error code

NetworkEndpoint GetLocalEndpoint()

Gets the local endpoint of the client.

Returns:

local endpoint

NetworkEndpoint GetRemoteEndpoint()

Gets the remote endpoint of the client.

Returns:

remote endpoint

esp_err_t SetRemoteEndpoint(IpV4Address address, uint16_t port)

Sets the IPv4 remote endpoint of the client.

Parameters:
  • address – IPv4 address

  • port – port

Returns:

error code

esp_err_t SetRemoteEndpoint(IpV6Address address, uint16_t port)

Sets the IPv6 remote endpoint of the client.

Parameters:
  • address – IPv6 address

  • port – port

Returns:

error code

std::shared_ptr<NetworkStream> GetStream()

Gets the client stream.

Returns:

stream