From 7546679e35775dea30c3cdcb85861f2cfb3841af Mon Sep 17 00:00:00 2001 From: tastopesato <52707232+tastopesato@users.noreply.github.com> Date: Wed, 21 Jan 2026 19:35:19 +0100 Subject: [PATCH] Fix compatibility with ESPHome 2026.1 The getpeername() function has been removed and replaced with getpeername_to(), which writes into a caller-owned span instead. --- components/stream_server/stream_server.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/stream_server/stream_server.cpp b/components/stream_server/stream_server.cpp index 5a5fb9b..94e3f9b 100644 --- a/components/stream_server/stream_server.cpp +++ b/components/stream_server/stream_server.cpp @@ -80,7 +80,15 @@ void StreamServerComponent::accept() { return; socket->setblocking(false); + +#if ESPHOME_VERSION_CODE >= VERSION_CODE(2026, 1, 0) + std::string identifier = std::string{esphome::socket::SOCKADDR_STR_LEN, 0}; + auto identifier_span = std::span(identifier.data(), identifier.size()); + identifier.resize(socket->getpeername_to(identifier_span)); +#else std::string identifier = socket->getpeername(); +#endif + this->clients_.emplace_back(std::move(socket), identifier, this->buf_head_); ESP_LOGD(TAG, "New client connected from %s", identifier.c_str()); this->publish_sensor();