ClearCore Library
Loading...
Searching...
No Matches
List of all members | Public Member Functions
ClearCore::EthernetTcpClient Class Reference

Detailed Description

ClearCore TCP client class.

This class manages interactions with a single Ethernet TCP client connection.

For more detailed information on the ClearCore Ethernet system, check out the ClearCore Ethernet informational page.

ClearCore TCP client class. More...

#include <EthernetTcpClient.h>

+ Inheritance diagram for ClearCore::EthernetTcpClient:
+ Collaboration diagram for ClearCore::EthernetTcpClient:

Public Member Functions

bool Connect (IpAddress ip, uint16_t port)
 Connects the client to a specified remote IP address and port.
 
bool Connected ()
 Determines if the client is actively connected to a server.
 
int16_t BytesAvailable ()
 Returns the number of bytes available to read.
 
int16_t Read ()
 Attempt to read the next available character.
 
int16_t Read (uint8_t *dataPtr, uint32_t length)
 Reads data received from the server.
 
int16_t Peek ()
 Attempt to get the next available character.
 
void Flush ()
 Wait until all outgoing data to the server has been sent.
 
void FlushInput ()
 Flush the received data.
 
void Close ()
 Close the client's connection to the server.
 
uint32_t Send (const uint8_t *buff, uint32_t size) override
 Send the buffer contents to the server.
 
uint32_t Send (uint8_t charToSend)
 Send a TCP packet.
 
uint32_t Send (const char *nullTermStr)
 Send a TCP packet.
 
uint16_t RemotePort ()
 Returns the remote port of the server this client is connected to.
 
IpAddress RemoteIp ()
 Returns the remote IP address of the server this client is connected to.
 
uint16_t ConnectionTimeout ()
 Returns the connection timeout.
 
void ConnectionTimeout (uint16_t timeout)
 Set the connection timeout. This is the maximum amount of time to wait for a server to accept this client after establishing initial communication with the server.
 

Member Function Documentation

◆ BytesAvailable()

int16_t ClearCore::EthernetTcpClient::BytesAvailable ( )

Returns the number of bytes available to read.

Returns
The number of bytes available to read.

◆ Connect()

bool ClearCore::EthernetTcpClient::Connect ( IpAddress  ip,
uint16_t  port 
)

Connects the client to a specified remote IP address and port.

Returns
True if the connection was successful.

◆ Connected()

bool ClearCore::EthernetTcpClient::Connected ( )

Determines if the client is actively connected to a server.

Returns
True if the client's connection is active. False if there is no connection or the existing connection is closed or closing.

◆ ConnectionTimeout() [1/2]

uint16_t ClearCore::EthernetTcpClient::ConnectionTimeout ( )
inline

Returns the connection timeout.

Returns
The connection timeout, in milliseconds.

◆ ConnectionTimeout() [2/2]

void ClearCore::EthernetTcpClient::ConnectionTimeout ( uint16_t  timeout)

Set the connection timeout. This is the maximum amount of time to wait for a server to accept this client after establishing initial communication with the server.

Parameters
[in]timeoutThe new connection timeout value, in milliseconds.
Note
Constrained between TCP_CONNECTION_TIMEOUT_MIN and TCP_CONNECTION_TIMEOUT_MAX in milliseconds.

◆ Flush()

void ClearCore::EthernetTcpClient::Flush ( )

Wait until all outgoing data to the server has been sent.

While the server is connected, blocks until the server has ACK'd all outgoing packets.

◆ Peek()

int16_t ClearCore::EthernetTcpClient::Peek ( )

Attempt to get the next available character.

Attempts to get the next available character without pulling the character out of the buffer.

Returns
The first character in the buffer, or -1 if no data is available.

◆ Read() [1/2]

int16_t ClearCore::EthernetTcpClient::Read ( )

Attempt to read the next available character.

Attempts to get the next available character from the client's incoming data buffer.

Returns
The character first character available, or -1 if no data is available.

◆ Read() [2/2]

int16_t ClearCore::EthernetTcpClient::Read ( uint8_t *  dataPtr,
uint32_t  length 
)

Reads data received from the server.

Parameters
[out]dataPtrA pointer to a buffer to hold the received data.
[in]lengthThe maximum number of bytes to read.
Returns
The number of bytes read.

◆ RemoteIp()

IpAddress ClearCore::EthernetTcpClient::RemoteIp ( )

Returns the remote IP address of the server this client is connected to.

Returns
The server's remote IP address.

◆ RemotePort()

uint16_t ClearCore::EthernetTcpClient::RemotePort ( )

Returns the remote port of the server this client is connected to.

Returns
The server's remote port.

◆ Send() [1/3]

uint32_t ClearCore::EthernetTcpClient::Send ( const char *  nullTermStr)
inline

Send a TCP packet.

Send a TCP packet to the remote with a string of characters as the payload.

Parameters
[in]nullTermStrA string to send to the remote.
Returns
The number of bytes written.

◆ Send() [2/3]

uint32_t ClearCore::EthernetTcpClient::Send ( const uint8_t *  buff,
uint32_t  size 
)
override

Send the buffer contents to the server.

Parameters
[in]buffA pointer to the beginning of the data to send.
[in]sizeThe maximum number of bytes to send.
Returns
The number of bytes sent to the server.
Note
The contents of the supplied buffer represents the payload in an outgoing TCP packet.

◆ Send() [3/3]

uint32_t ClearCore::EthernetTcpClient::Send ( uint8_t  charToSend)
inline

Send a TCP packet.

Send a TCP packet to the remote with a single character as the payload.

Parameters
[in]charToSendA character to send to the remote.
Returns
The number of bytes written.

The documentation for this class was generated from the following file: