diff --git a/src/AsyncTCP.cpp b/src/AsyncTCP.cpp index cab5ec8..e0f301c 100644 --- a/src/AsyncTCP.cpp +++ b/src/AsyncTCP.cpp @@ -802,6 +802,19 @@ void AsyncClient::close(bool now) if (_socket != -1) _close(); } +int8_t AsyncClient::abort(){ + if (_socket != -1) { + // Note: needs LWIP_SO_LINGER to be enabled in order to work, otherwise + // this call is equivalent to close(). + struct linger l; + l.l_onoff = 1; + l.l_linger = 0; + setsockopt(_socket, SOL_SOCKET, SO_LINGER, &l, sizeof(l)); + _close(); + } + return ERR_ABRT; +} + const char * AsyncClient::errorToString(int8_t error){ switch(error){ case ERR_OK: return "OK"; diff --git a/src/AsyncTCP.h b/src/AsyncTCP.h index 943edaa..6ac9601 100644 --- a/src/AsyncTCP.h +++ b/src/AsyncTCP.h @@ -87,7 +87,7 @@ class AsyncClient : public AsyncSocketBase bool connect(const char* host, uint16_t port); void close(bool now = false); - //int8_t abort(); + int8_t abort(); bool free(); bool canSend() { return space() > 0; }