From d1d3d256a9663c87a833efe6efc4a73c558ad605 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 19 Feb 2026 00:37:23 -0600 Subject: [PATCH] [socket] Log error when UDP socket requested on LWIP TCP-only platforms The LWIP raw socket factory only supports TCP but silently ignored the type parameter, returning a TCP socket for SOCK_DGRAM requests. This caused components expecting UDP to fail silently with no indication of why. Return nullptr with EPROTOTYPE and log an error instead. --- esphome/components/socket/lwip_raw_tcp_impl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/esphome/components/socket/lwip_raw_tcp_impl.cpp b/esphome/components/socket/lwip_raw_tcp_impl.cpp index aa37386d70..6e95f5bc7a 100644 --- a/esphome/components/socket/lwip_raw_tcp_impl.cpp +++ b/esphome/components/socket/lwip_raw_tcp_impl.cpp @@ -680,6 +680,11 @@ class LWIPRawListenImpl final : public LWIPRawImpl { }; std::unique_ptr socket(int domain, int type, int protocol) { + if (type != SOCK_STREAM) { + ESP_LOGE(TAG, "UDP sockets not supported on this platform, use WiFiUDP"); + errno = EPROTOTYPE; + return nullptr; + } auto *pcb = tcp_new(); if (pcb == nullptr) return nullptr;