[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.
This commit is contained in:
J. Nick Koston
2026-02-19 00:37:23 -06:00
parent 4d05e4d576
commit d1d3d256a9

View File

@@ -680,6 +680,11 @@ class LWIPRawListenImpl final : public LWIPRawImpl {
};
std::unique_ptr<Socket> 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;