mirror of
				https://github.com/eledio-devices/thirdparty-AsyncTCPSock.git
				synced 2025-10-31 16:14:15 +01:00 
			
		
		
		
	Add abort() support if enabled in LWIP
This commit is contained in:
		| @@ -802,6 +802,19 @@ void AsyncClient::close(bool now) | |||||||
|     if (_socket != -1) _close(); |     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){ | const char * AsyncClient::errorToString(int8_t error){ | ||||||
|     switch(error){ |     switch(error){ | ||||||
|         case ERR_OK: return "OK"; |         case ERR_OK: return "OK"; | ||||||
|   | |||||||
| @@ -87,7 +87,7 @@ class AsyncClient : public AsyncSocketBase | |||||||
|     bool connect(const char* host, uint16_t port); |     bool connect(const char* host, uint16_t port); | ||||||
|     void close(bool now = false); |     void close(bool now = false); | ||||||
|  |  | ||||||
|     //int8_t abort(); |     int8_t abort(); | ||||||
|     bool free(); |     bool free(); | ||||||
|  |  | ||||||
|     bool canSend() { return space() > 0; } |     bool canSend() { return space() > 0; } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user