mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 17:05:36 +00:00
eliminate duplicate socket_listen* symbols on BSD/LWIP_SOCKETS
This commit is contained in:
@@ -95,14 +95,6 @@ std::unique_ptr<Socket> socket_loop_monitored(int domain, int type, int protocol
|
||||
return create_socket(domain, type, protocol, true);
|
||||
}
|
||||
|
||||
std::unique_ptr<ListenSocket> socket_listen(int domain, int type, int protocol) {
|
||||
return create_socket(domain, type, protocol, false);
|
||||
}
|
||||
|
||||
std::unique_ptr<ListenSocket> socket_listen_loop_monitored(int domain, int type, int protocol) {
|
||||
return create_socket(domain, type, protocol, true);
|
||||
}
|
||||
|
||||
} // namespace esphome::socket
|
||||
|
||||
#endif // USE_SOCKET_IMPL_BSD_SOCKETS
|
||||
|
||||
@@ -95,14 +95,6 @@ std::unique_ptr<Socket> socket_loop_monitored(int domain, int type, int protocol
|
||||
return create_socket(domain, type, protocol, true);
|
||||
}
|
||||
|
||||
std::unique_ptr<ListenSocket> socket_listen(int domain, int type, int protocol) {
|
||||
return create_socket(domain, type, protocol, false);
|
||||
}
|
||||
|
||||
std::unique_ptr<ListenSocket> socket_listen_loop_monitored(int domain, int type, int protocol) {
|
||||
return create_socket(domain, type, protocol, true);
|
||||
}
|
||||
|
||||
} // namespace esphome::socket
|
||||
|
||||
#endif // USE_SOCKET_IMPL_LWIP_SOCKETS
|
||||
|
||||
@@ -89,6 +89,9 @@ std::unique_ptr<Socket> socket_ip(int type, int protocol) {
|
||||
#endif /* USE_NETWORK_IPV6 */
|
||||
}
|
||||
|
||||
#ifdef USE_SOCKET_IMPL_LWIP_TCP
|
||||
// LWIP_TCP has separate Socket/ListenSocket types — needs out-of-line factory.
|
||||
// BSD and LWIP_SOCKETS define this inline in socket.h.
|
||||
std::unique_ptr<ListenSocket> socket_ip_loop_monitored(int type, int protocol) {
|
||||
#if USE_NETWORK_IPV6
|
||||
return socket_listen_loop_monitored(AF_INET6, type, protocol);
|
||||
@@ -96,6 +99,7 @@ std::unique_ptr<ListenSocket> socket_ip_loop_monitored(int type, int protocol) {
|
||||
return socket_listen_loop_monitored(AF_INET, type, protocol);
|
||||
#endif /* USE_NETWORK_IPV6 */
|
||||
}
|
||||
#endif
|
||||
|
||||
socklen_t set_sockaddr(struct sockaddr *addr, socklen_t addrlen, const char *ip_address, uint16_t port) {
|
||||
#if USE_NETWORK_IPV6
|
||||
|
||||
@@ -77,11 +77,29 @@ std::unique_ptr<Socket> socket_ip(int type, int protocol);
|
||||
std::unique_ptr<Socket> socket_loop_monitored(int domain, int type, int protocol);
|
||||
|
||||
/// Create a listening socket of the given domain, type and protocol.
|
||||
std::unique_ptr<ListenSocket> socket_listen(int domain, int type, int protocol);
|
||||
/// Create a listening socket and monitor it for data in the main loop.
|
||||
std::unique_ptr<ListenSocket> socket_listen_loop_monitored(int domain, int type, int protocol);
|
||||
/// Create a listening socket in the newest available IP domain and monitor it.
|
||||
#ifdef USE_SOCKET_IMPL_LWIP_TCP
|
||||
// LWIP_TCP has separate Socket/ListenSocket types — needs distinct factory functions.
|
||||
std::unique_ptr<ListenSocket> socket_listen(int domain, int type, int protocol);
|
||||
std::unique_ptr<ListenSocket> socket_listen_loop_monitored(int domain, int type, int protocol);
|
||||
std::unique_ptr<ListenSocket> socket_ip_loop_monitored(int type, int protocol);
|
||||
#else
|
||||
// BSD and LWIP_SOCKETS: Socket == ListenSocket, so listen variants just delegate.
|
||||
inline std::unique_ptr<ListenSocket> socket_listen(int domain, int type, int protocol) {
|
||||
return socket(domain, type, protocol);
|
||||
}
|
||||
inline std::unique_ptr<ListenSocket> socket_listen_loop_monitored(int domain, int type, int protocol) {
|
||||
return socket_loop_monitored(domain, type, protocol);
|
||||
}
|
||||
inline std::unique_ptr<ListenSocket> socket_ip_loop_monitored(int type, int protocol) {
|
||||
#if USE_NETWORK_IPV6
|
||||
return socket_loop_monitored(AF_INET6, type, protocol);
|
||||
#else
|
||||
return socket_loop_monitored(AF_INET, type, protocol);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Set a sockaddr to the specified address and port for the IP version used by socket_ip().
|
||||
/// @param addr Destination sockaddr structure
|
||||
|
||||
Reference in New Issue
Block a user