ESPHome 2026.3.0-dev
Loading...
Searching...
No Matches
esphome::socket::BSDSocketImpl Class Reference

#include <bsd_sockets_impl.h>

Public Member Functions

 BSDSocketImpl (int fd, bool monitor_loop=false)
 
 ~BSDSocketImpl ()
 
 BSDSocketImpl (const BSDSocketImpl &)=delete
 
BSDSocketImploperator= (const BSDSocketImpl &)=delete
 
int connect (const struct sockaddr *addr, socklen_t addrlen)
 
std::unique_ptr< BSDSocketImplaccept (struct sockaddr *addr, socklen_t *addrlen)
 
std::unique_ptr< BSDSocketImplaccept_loop_monitored (struct sockaddr *addr, socklen_t *addrlen)
 
int bind (const struct sockaddr *addr, socklen_t addrlen)
 
int close ()
 
int shutdown (int how)
 
int getpeername (struct sockaddr *addr, socklen_t *addrlen)
 
int getsockname (struct sockaddr *addr, socklen_t *addrlen)
 
size_t getpeername_to (std::span< char, SOCKADDR_STR_LEN > buf)
 Format peer address into a fixed-size buffer (no heap allocation)
 
size_t getsockname_to (std::span< char, SOCKADDR_STR_LEN > buf)
 Format local address into a fixed-size buffer (no heap allocation)
 
int getsockopt (int level, int optname, void *optval, socklen_t *optlen)
 
int setsockopt (int level, int optname, const void *optval, socklen_t optlen)
 
int listen (int backlog)
 
ssize_t read (void *buf, size_t len)
 
ssize_t recvfrom (void *buf, size_t len, sockaddr *addr, socklen_t *addr_len)
 
ssize_t readv (const struct iovec *iov, int iovcnt)
 
ssize_t write (const void *buf, size_t len)
 
ssize_t send (const void *buf, size_t len, int flags)
 
ssize_t writev (const struct iovec *iov, int iovcnt)
 
ssize_t sendto (const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen)
 
int setblocking (bool blocking)
 
int loop ()
 
bool ready () const
 
int get_fd () const
 

Protected Attributes

int fd_ {-1}
 
bool closed_ {false}
 
bool loop_monitored_ {false}
 

Detailed Description

Definition at line 18 of file bsd_sockets_impl.h.

Constructor & Destructor Documentation

◆ BSDSocketImpl() [1/2]

esphome::socket::BSDSocketImpl::BSDSocketImpl ( int fd,
bool monitor_loop = false )

Definition at line 12 of file bsd_sockets_impl.cpp.

◆ ~BSDSocketImpl()

esphome::socket::BSDSocketImpl::~BSDSocketImpl ( )

Definition at line 21 of file bsd_sockets_impl.cpp.

◆ BSDSocketImpl() [2/2]

esphome::socket::BSDSocketImpl::BSDSocketImpl ( const BSDSocketImpl & )
delete

Member Function Documentation

◆ accept()

std::unique_ptr< BSDSocketImpl > esphome::socket::BSDSocketImpl::accept ( struct sockaddr * addr,
socklen_t * addrlen )
inline

Definition at line 26 of file bsd_sockets_impl.h.

◆ accept_loop_monitored()

std::unique_ptr< BSDSocketImpl > esphome::socket::BSDSocketImpl::accept_loop_monitored ( struct sockaddr * addr,
socklen_t * addrlen )
inline

Definition at line 32 of file bsd_sockets_impl.h.

◆ bind()

int esphome::socket::BSDSocketImpl::bind ( const struct sockaddr * addr,
socklen_t addrlen )
inline

Definition at line 39 of file bsd_sockets_impl.h.

◆ close()

int esphome::socket::BSDSocketImpl::close ( )

Definition at line 27 of file bsd_sockets_impl.cpp.

◆ connect()

int esphome::socket::BSDSocketImpl::connect ( const struct sockaddr * addr,
socklen_t addrlen )
inline

Definition at line 25 of file bsd_sockets_impl.h.

◆ get_fd()

int esphome::socket::BSDSocketImpl::get_fd ( ) const
inline

Definition at line 104 of file bsd_sockets_impl.h.

◆ getpeername()

int esphome::socket::BSDSocketImpl::getpeername ( struct sockaddr * addr,
socklen_t * addrlen )
inline

Definition at line 43 of file bsd_sockets_impl.h.

◆ getpeername_to()

size_t esphome::socket::BSDSocketImpl::getpeername_to ( std::span< char, SOCKADDR_STR_LEN > buf)

Format peer address into a fixed-size buffer (no heap allocation)

Definition at line 53 of file bsd_sockets_impl.cpp.

◆ getsockname()

int esphome::socket::BSDSocketImpl::getsockname ( struct sockaddr * addr,
socklen_t * addrlen )
inline

Definition at line 44 of file bsd_sockets_impl.h.

◆ getsockname_to()

size_t esphome::socket::BSDSocketImpl::getsockname_to ( std::span< char, SOCKADDR_STR_LEN > buf)

Format local address into a fixed-size buffer (no heap allocation)

Definition at line 63 of file bsd_sockets_impl.cpp.

◆ getsockopt()

int esphome::socket::BSDSocketImpl::getsockopt ( int level,
int optname,
void * optval,
socklen_t * optlen )
inline

Definition at line 51 of file bsd_sockets_impl.h.

◆ listen()

int esphome::socket::BSDSocketImpl::listen ( int backlog)
inline

Definition at line 57 of file bsd_sockets_impl.h.

◆ loop()

int esphome::socket::BSDSocketImpl::loop ( )
inline

Definition at line 100 of file bsd_sockets_impl.h.

◆ operator=()

BSDSocketImpl & esphome::socket::BSDSocketImpl::operator= ( const BSDSocketImpl & )
delete

◆ read()

ssize_t esphome::socket::BSDSocketImpl::read ( void * buf,
size_t len )
inline

Definition at line 58 of file bsd_sockets_impl.h.

◆ readv()

ssize_t esphome::socket::BSDSocketImpl::readv ( const struct iovec * iov,
int iovcnt )
inline

Definition at line 72 of file bsd_sockets_impl.h.

◆ ready()

bool esphome::socket::BSDSocketImpl::ready ( ) const

Definition at line 51 of file bsd_sockets_impl.cpp.

◆ recvfrom()

ssize_t esphome::socket::BSDSocketImpl::recvfrom ( void * buf,
size_t len,
sockaddr * addr,
socklen_t * addr_len )
inline

Definition at line 65 of file bsd_sockets_impl.h.

◆ send()

ssize_t esphome::socket::BSDSocketImpl::send ( const void * buf,
size_t len,
int flags )
inline

Definition at line 86 of file bsd_sockets_impl.h.

◆ sendto()

ssize_t esphome::socket::BSDSocketImpl::sendto ( const void * buf,
size_t len,
int flags,
const struct sockaddr * to,
socklen_t tolen )
inline

Definition at line 95 of file bsd_sockets_impl.h.

◆ setblocking()

int esphome::socket::BSDSocketImpl::setblocking ( bool blocking)

Definition at line 40 of file bsd_sockets_impl.cpp.

◆ setsockopt()

int esphome::socket::BSDSocketImpl::setsockopt ( int level,
int optname,
const void * optval,
socklen_t optlen )
inline

Definition at line 54 of file bsd_sockets_impl.h.

◆ shutdown()

int esphome::socket::BSDSocketImpl::shutdown ( int how)
inline

Definition at line 41 of file bsd_sockets_impl.h.

◆ write()

ssize_t esphome::socket::BSDSocketImpl::write ( const void * buf,
size_t len )
inline

Definition at line 79 of file bsd_sockets_impl.h.

◆ writev()

ssize_t esphome::socket::BSDSocketImpl::writev ( const struct iovec * iov,
int iovcnt )
inline

Definition at line 87 of file bsd_sockets_impl.h.

Field Documentation

◆ closed_

bool esphome::socket::BSDSocketImpl::closed_ {false}
protected

Definition at line 108 of file bsd_sockets_impl.h.

◆ fd_

int esphome::socket::BSDSocketImpl::fd_ {-1}
protected

Definition at line 107 of file bsd_sockets_impl.h.

◆ loop_monitored_

bool esphome::socket::BSDSocketImpl::loop_monitored_ {false}
protected

Definition at line 109 of file bsd_sockets_impl.h.


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