ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
esphome::socket::Ipv4Resolve Class Reference

One IPv4 literal or hostname. Must outlive a pending lookup. More...

#include <ipv4_resolve.h>

Public Member Functions

void forget ()
 Drop the stored address so the next start() resolves again.
 
bool consume_failure ()
 Drop a failed lookup so the next start() tries again.
 
bool ready () const
 
socklen_t to_sockaddr (struct sockaddr *dest, socklen_t destlen, uint16_t port) const
 Write the stored address into dest. Returns 0 until ready() is true.
 
void start (const char *host, uint16_t port, const char *tag)
 Resolve host; tag names the failure log.
 

Static Public Attributes

static constexpr uint8_t STATE_IDLE = 0
 
static constexpr uint8_t STATE_RESOLVING = 1
 
static constexpr uint8_t STATE_RESOLVED = 2
 
static constexpr uint8_t STATE_FAILED = 3
 
static constexpr uint8_t STATE_PUBLISHING = 4
 

Detailed Description

One IPv4 literal or hostname. Must outlive a pending lookup.

Definition at line 29 of file ipv4_resolve.h.

Member Function Documentation

◆ consume_failure()

bool esphome::socket::Ipv4Resolve::consume_failure ( )

Drop a failed lookup so the next start() tries again.

Definition at line 21 of file ipv4_resolve.cpp.

◆ forget()

void esphome::socket::Ipv4Resolve::forget ( )

Drop the stored address so the next start() resolves again.

A result already publishing may still land, so ready() can be true right after this; after changing hosts, forget() until ready() is false.

Definition at line 34 of file ipv4_resolve.cpp.

◆ ready()

bool esphome::socket::Ipv4Resolve::ready ( ) const
inline

Definition at line 44 of file ipv4_resolve.h.

◆ start()

void esphome::socket::Ipv4Resolve::start ( const char * host,
uint16_t port,
const char * tag )

Resolve host; tag names the failure log.

On host and Zephyr this blocks in getaddrinfo().

Definition at line 141 of file ipv4_resolve.cpp.

◆ to_sockaddr()

socklen_t esphome::socket::Ipv4Resolve::to_sockaddr ( struct sockaddr * dest,
socklen_t destlen,
uint16_t port ) const

Write the stored address into dest. Returns 0 until ready() is true.

Definition at line 62 of file ipv4_resolve.cpp.

Field Documentation

◆ STATE_FAILED

uint8_t esphome::socket::Ipv4Resolve::STATE_FAILED = 3
staticconstexpr

Definition at line 34 of file ipv4_resolve.h.

◆ STATE_IDLE

uint8_t esphome::socket::Ipv4Resolve::STATE_IDLE = 0
staticconstexpr

Definition at line 31 of file ipv4_resolve.h.

◆ STATE_PUBLISHING

uint8_t esphome::socket::Ipv4Resolve::STATE_PUBLISHING = 4
staticconstexpr

Definition at line 36 of file ipv4_resolve.h.

◆ STATE_RESOLVED

uint8_t esphome::socket::Ipv4Resolve::STATE_RESOLVED = 2
staticconstexpr

Definition at line 33 of file ipv4_resolve.h.

◆ STATE_RESOLVING

uint8_t esphome::socket::Ipv4Resolve::STATE_RESOLVING = 1
staticconstexpr

Definition at line 32 of file ipv4_resolve.h.


The documentation for this class was generated from the following files: