diff --git a/components/wifi/esp8266-driver/ESP8266Interface.cpp b/components/wifi/esp8266-driver/ESP8266Interface.cpp index 72c9a7fd07a..e64e617de60 100644 --- a/components/wifi/esp8266-driver/ESP8266Interface.cpp +++ b/components/wifi/esp8266-driver/ESP8266Interface.cpp @@ -505,9 +505,11 @@ int ESP8266Interface::socket_send(void *handle, const void *data, unsigned size) } while ((sendStartTime - rtos::Kernel::get_ms_count() < 50) && (status != NSAPI_ERROR_OK)); - if (status == NSAPI_ERROR_WOULD_BLOCK) { - debug("Enqueuing the event call"); + if (status == NSAPI_ERROR_WOULD_BLOCK && socket->proto == NSAPI_TCP) { + tr_debug("ESP8266Interface::socket_send(): enqueuing the event call"); _global_event_queue->call_in(100, callback(this, &ESP8266Interface::event)); + } else if (status == NSAPI_ERROR_WOULD_BLOCK && socket->proto == NSAPI_UDP) { + status = NSAPI_ERROR_DEVICE_ERROR; } return status != NSAPI_ERROR_OK ? status : size;