1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Add support WiFiClientSecure TCP KeepAlive (#8940)

* Add support WiFiClientSecure TCP KeepAlive
* Make TCP keepalive and related functions virtual.
* Make TCP keepalive and related functions override.

Fixes #8939
This commit is contained in:
Suwatchai K 2023-06-12 01:11:38 +07:00 committed by GitHub
parent 57fa6cdc92
commit e05656bd78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 6 deletions

View File

@ -107,12 +107,12 @@ public:
static void stopAll(); static void stopAll();
static void stopAllExcept(WiFiClient * c); static void stopAllExcept(WiFiClient * c);
void keepAlive (uint16_t idle_sec = TCP_DEFAULT_KEEPALIVE_IDLE_SEC, uint16_t intv_sec = TCP_DEFAULT_KEEPALIVE_INTERVAL_SEC, uint8_t count = TCP_DEFAULT_KEEPALIVE_COUNT); virtual void keepAlive (uint16_t idle_sec = TCP_DEFAULT_KEEPALIVE_IDLE_SEC, uint16_t intv_sec = TCP_DEFAULT_KEEPALIVE_INTERVAL_SEC, uint8_t count = TCP_DEFAULT_KEEPALIVE_COUNT);
bool isKeepAliveEnabled () const; virtual bool isKeepAliveEnabled () const;
uint16_t getKeepAliveIdle () const; virtual uint16_t getKeepAliveIdle () const;
uint16_t getKeepAliveInterval () const; virtual uint16_t getKeepAliveInterval () const;
uint8_t getKeepAliveCount () const; virtual uint8_t getKeepAliveCount () const;
void disableKeepAlive () { keepAlive(0, 0, 0); } virtual void disableKeepAlive () { keepAlive(0, 0, 0); }
// default NoDelay=False (Nagle=True=!NoDelay) // default NoDelay=False (Nagle=True=!NoDelay)
// Nagle is for shortly delaying outgoing data, to send less/bigger packets // Nagle is for shortly delaying outgoing data, to send less/bigger packets

View File

@ -358,6 +358,21 @@ class WiFiClientSecure : public WiFiClient {
// consume bytes after use (see peekBuffer) // consume bytes after use (see peekBuffer)
virtual void peekConsume (size_t consume) override { return _ctx->peekConsume(consume); } virtual void peekConsume (size_t consume) override { return _ctx->peekConsume(consume); }
void keepAlive(uint16_t idle_sec = TCP_DEFAULT_KEEPALIVE_IDLE_SEC, uint16_t intv_sec = TCP_DEFAULT_KEEPALIVE_INTERVAL_SEC, uint8_t count = TCP_DEFAULT_KEEPALIVE_COUNT) override
{
_ctx->keepAlive(idle_sec, intv_sec, count);
}
bool isKeepAliveEnabled() const override { return _ctx->isKeepAliveEnabled(); };
uint16_t getKeepAliveIdle() const override { return _ctx->getKeepAliveIdle(); };
uint16_t getKeepAliveInterval() const override { return _ctx->getKeepAliveInterval(); };
uint8_t getKeepAliveCount() const override { return _ctx->getKeepAliveCount(); };
void disableKeepAlive() override { _ctx->disableKeepAlive(); };
private: private:
std::shared_ptr<WiFiClientSecureCtx> _ctx; std::shared_ptr<WiFiClientSecureCtx> _ctx;