Add abort() support if enabled in LWIP

This commit is contained in:
Alex Villacís Lasso
2020-12-21 14:04:00 -05:00
parent de2a0da915
commit 9ee3bda5ae
2 changed files with 14 additions and 1 deletions

View File

@@ -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";

View File

@@ -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; }