![]() |
ClearCore Library
|
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. | |
| int16_t ClearCore::EthernetTcpClient::BytesAvailable | ( | ) |
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.
| bool ClearCore::EthernetTcpClient::Connected | ( | ) |
Determines if the client is actively connected to a server.
|
inline |
Returns the connection timeout.
| 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.
| [in] | timeout | The new connection timeout value, 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.
| 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.
| int16_t ClearCore::EthernetTcpClient::Read | ( | uint8_t * | dataPtr, |
| uint32_t | length | ||
| ) |
Reads data received from the server.
| [out] | dataPtr | A pointer to a buffer to hold the received data. |
| [in] | length | The maximum number of bytes to read. |
| IpAddress ClearCore::EthernetTcpClient::RemoteIp | ( | ) |
Returns the remote IP address of the server this client is connected to.
| uint16_t ClearCore::EthernetTcpClient::RemotePort | ( | ) |
Returns the remote port of the server this client is connected to.
|
inline |
Send a TCP packet.
Send a TCP packet to the remote with a string of characters as the payload.
| [in] | nullTermStr | A string to send to the remote. |
|
override |
Send the buffer contents to the server.
| [in] | buff | A pointer to the beginning of the data to send. |
| [in] | size | The maximum number of bytes to send. |
|
inline |
Send a TCP packet.
Send a TCP packet to the remote with a single character as the payload.
| [in] | charToSend | A character to send to the remote. |