5#if defined(USE_SOCKET_IMPL_LWIP_TCP) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS) || defined(USE_SOCKET_IMPL_BSD_SOCKETS)
49 void adopt(std::unique_ptr<Socket> sock);
81 size_t queue_(uint8_t *tx,
const uint8_t *data,
size_t len);
94 void drop_(
const LogString *what,
int err);
132 size_t queue(uint8_t *tx,
const uint8_t *data,
size_t len) {
return this->
queue_(tx, data,
len); }
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
StringRef is a reference to a string owned by something else.
constexpr const char * c_str() const
One IPv4 literal or hostname. Must outlive a pending lookup.
A reconnecting TCP stream driven from loop().
uint32_t last_io() const
When a byte last moved, or note_io() last ran.
uint32_t reconnect_interval() const
void close()
Close without scheduling a reconnect (shutdown).
void adopt(std::unique_ptr< Socket > sock)
Take over an accepted socket (the server side of a bridge).
void flush_tx_slow_(uint8_t *tx)
void note_attempt()
Shared retry clock, also usable for a listen socket.
uint32_t idle_timeout() const
uint32_t reconnect_interval_ms_
bool connecting() const
A connect attempt is in flight.
void set_host(const char *host)
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.
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 idle_close_()
Log and close after check_idle() saw the timeout pass; schedules the next attempt like a failure.
void tx_commit(size_t len)
void set_port(uint16_t port)
void poll()
Connect state machine; call every loop while acting as a client.
void check_idle()
Close when no byte has moved for idle_timeout(). Inline: the close runs only once that time has passe...
uint32_t last_attempt_ms_
static constexpr size_t TX_BUFFER_SIZE
uint32_t idle_timeout_ms_
void drop_(const LogString *what, int err)
Close after a failure, log what and errno, schedule the next attempt.
void note_io()
Restart the idle clock.
void set_idle_timeout(uint32_t ms)
0 leaves the link up.
std::unique_ptr< Socket > sock_
void begin(const char *tag)
Call from setup(). tag names this link's log lines.
ssize_t read(uint8_t *buf, size_t len)
Returns bytes moved, 0 when nothing can move now, -1 when the link dropped.
void set_reconnect_interval(uint32_t ms)
const char * host() const
bool flush_tx_(uint8_t *tx)
A link with its own outgoing buffer.
uint8_t tx_[TX_BUFFER_SIZE]
bool flush_tx()
Send the front of the buffer; true once it is empty.
uint8_t * tx_tail()
Direct access to the buffer's free tail.
size_t queue(const uint8_t *data, size_t len)
Copy into the outgoing buffer; returns how many bytes fit.
A link whose outgoing buffer belongs to its owner, so several links can share one.
size_t queue(uint8_t *tx, const uint8_t *data, size_t len)
bool flush_tx(uint8_t *tx)
Application App
Global storage of Application pointer - only one Application can exist.