|
ESPHome 2026.12.0-dev
|
A link whose outgoing buffer belongs to its owner, so several links can share one. More...
#include <tcp_client_link.h>
Public Member Functions | |
| size_t | queue (uint8_t *tx, const uint8_t *data, size_t len) |
| bool | flush_tx (uint8_t *tx) |
Public Member Functions inherited from esphome::socket::TcpClientLinkBase | |
| void | set_host (const char *host) |
| void | set_port (uint16_t port) |
| void | set_reconnect_interval (uint32_t ms) |
| void | set_idle_timeout (uint32_t ms) |
| 0 leaves the link up. | |
| const char * | host () const |
| uint16_t | port () const |
| uint32_t | reconnect_interval () const |
| uint32_t | idle_timeout () const |
| void | begin (const char *tag) |
| Call from setup(). tag names this link's log lines. | |
| void | poll () |
| Connect state machine; call every loop while acting as a client. | |
| void | adopt (std::unique_ptr< Socket > sock) |
| Take over an accepted socket (the server side of a bridge). | |
| ssize_t | read (uint8_t *buf, size_t len) |
| Returns bytes moved, 0 when nothing can move now, -1 when the link dropped. | |
| void | tx_commit (size_t len) |
| size_t | tx_free () const |
| void | close () |
| Close without scheduling a reconnect (shutdown). | |
| void | note_io () |
| Restart the idle clock. | |
| uint32_t | last_io () const |
| When a byte last moved, or note_io() last ran. | |
| void | check_idle () |
| Close when no byte has moved for idle_timeout(). Inline: the close runs only once that time has passed. | |
| bool | connected () const |
| bool | connecting () const |
| A connect attempt is in flight. | |
| bool | ready () const |
| void | note_attempt () |
| Shared retry clock, also usable for a listen socket. | |
| bool | in_backoff () const |
Additional Inherited Members | |
Static Public Attributes inherited from esphome::socket::TcpClientLinkBase | |
| static constexpr size_t | TX_BUFFER_SIZE = 1024 |
Protected Member Functions inherited from esphome::socket::TcpClientLinkBase | |
| size_t | queue_ (uint8_t *tx, const uint8_t *data, size_t len) |
| queue() and flush_tx() of the subclasses, on the buffer they keep. | |
| bool | flush_tx_ (uint8_t *tx) |
| ssize_t | write_ (const uint8_t *buf, size_t len) |
| The raw stream write behind flush_tx(); drops the link on a fatal error. | |
| void | flush_tx_slow_ (uint8_t *tx) |
| void | poll_slow_ () |
| void | try_connect_ () |
| void | drop_ (const LogString *what, int err) |
| Close after a failure, log what and errno, schedule the next attempt. | |
| void | idle_close_ () |
| Log and close after check_idle() saw the timeout pass; schedules the next attempt like a failure. | |
Protected Attributes inherited from esphome::socket::TcpClientLinkBase | |
| StringRef | host_ |
| std::unique_ptr< Socket > | sock_ |
| const char * | tag_ {nullptr} |
| uint32_t | last_attempt_ms_ {0} |
| uint32_t | reconnect_interval_ms_ {5000} |
| uint32_t | last_io_ms_ {0} |
| uint32_t | idle_timeout_ms_ {0} |
| Ipv4Resolve | resolved_ |
| uint16_t | port_ {0} |
| uint16_t | tx_len_ {0} |
| bool | connected_ {false} |
A link whose outgoing buffer belongs to its owner, so several links can share one.
tx holds TX_BUFFER_SIZE bytes. Only one link may hold bytes in it: the owner queues to another only after flush_tx() emptied the last.
Definition at line 130 of file tcp_client_link.h.
|
inline |
Definition at line 133 of file tcp_client_link.h.
|
inline |
Definition at line 132 of file tcp_client_link.h.