Skip to content

ESPHome 2026.3.0: Socket abstraction layer devirtualized #154

@bdraco

Description

@bdraco

Summary

ESPHome 2026.3.0 devirtualizes the socket abstraction layer (PR #14398). socket::Socket and socket::ListenSocket are now concrete type aliases instead of virtual base classes. Code using std::unique_ptr<socket::Socket> with virtual dispatch will need to update.

Current usage

Uses std::unique_ptr<socket::Socket> for UDP sockets and calls socket::socket_ip_loop_monitored(), bind(), recvfrom() via virtual dispatch.

Recommended migration

  • socket::Socket is now a type alias for the platform-specific socket implementation — std::unique_ptr<socket::Socket> still works
  • socket::socket_ip() and socket::socket_ip_loop_monitored() still return std::unique_ptr<socket::Socket>
  • Listen sockets must use socket::ListenSocket instead of socket::Socket
  • If you were subclassing socket::Socket to create a custom socket implementation, that pattern is no longer supported

See the blog post for detailed migration examples.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions