2 #if defined(USE_SOCKET_IMPL_LWIP_TCP) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS) || defined(USE_SOCKET_IMPL_BSD_SOCKETS) 15 return socket(AF_INET6, type, protocol);
17 return socket(AF_INET, type, protocol);
23 if (ip_address.find(
':') != std::string::npos) {
30 server->sin6_family = AF_INET6;
31 server->sin6_port = htons(port);
34 inet6_aton(ip_address.c_str(), &ip6);
35 memcpy(server->sin6_addr.un.u32_addr, ip6.addr,
sizeof(ip6.addr));
43 auto *server =
reinterpret_cast<sockaddr_in *
>(addr);
45 server->sin_family = AF_INET;
46 server->sin_addr.s_addr = inet_addr(ip_address.c_str());
47 server->sin_port = htons(port);
59 server->sin6_family = AF_INET6;
60 server->sin6_port = htons(port);
61 server->sin6_addr = IN6ADDR_ANY_INIT;
68 auto *server =
reinterpret_cast<sockaddr_in *
>(addr);
70 server->sin_family = AF_INET;
71 server->sin_addr.s_addr = ESPHOME_INADDR_ANY;
72 server->sin_port = htons(port);
std::unique_ptr< Socket > socket_ip(int type, int protocol)
Create a socket in the newest available IP domain (IPv6 or IPv4) of the given type and protocol...
socklen_t set_sockaddr_any(struct sockaddr *addr, socklen_t addrlen, uint16_t port)
Set a sockaddr to the any address and specified port for the IP version used by socket_ip().
Implementation of SPI Controller mode.
socklen_t set_sockaddr(struct sockaddr *addr, socklen_t addrlen, const std::string &ip_address, uint16_t port)
Set a sockaddr to the specified address and port for the IP version used by socket_ip().
std::unique_ptr< Socket > socket(int domain, int type, int protocol)
Create a socket of the given domain, type and protocol.