ClearCore Library
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. More...
 
bool Connected ()
 Determines if the client is actively connected to a server. More...
 
int16_t BytesAvailable ()
 Returns the number of bytes available to read. More...
 
int16_t Read ()
 Attempt to read the next available character. More...
 
int16_t Read (uint8_t *dataPtr, uint32_t length)
 Reads data received from the server. More...
 
int16_t Peek ()
 Attempt to get the next available character. More...
 
void Flush ()
 Wait until all outgoing data to the server has been sent. More...
 
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. More...
 
uint32_t Send (uint8_t charToSend)
 Send a TCP packet. More...
 
uint32_t Send (const char *nullTermStr)
 Send a TCP packet. More...
 
uint16_t RemotePort ()
 Returns the remote port of the server this client is connected to. More...
 
IpAddress RemoteIp ()
 Returns the remote IP address of the server this client is connected to. More...
 
uint16_t ConnectionTimeout ()
 Returns the connection timeout. More...
 
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. More...
 

Member Function Documentation

int16_t ClearCore::EthernetTcpClient::BytesAvailable ( )

Returns the number of bytes available to read.

Returns
The number of bytes available to read.
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.
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.
uint16_t ClearCore::EthernetTcpClient::ConnectionTimeout ( )
inline

Returns the connection timeout.

Returns
The connection timeout, in milliseconds.
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.
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.

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.
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.
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.
IpAddress ClearCore::EthernetTcpClient::RemoteIp ( )

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

Returns
The server's remote IP address.
uint16_t ClearCore::EthernetTcpClient::RemotePort ( )

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

Returns
The server's remote port.
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.
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.
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.

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