summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--louloulibs/network/tcp_client_socket_handler.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/louloulibs/network/tcp_client_socket_handler.cpp b/louloulibs/network/tcp_client_socket_handler.cpp
index 4e6445c..530c3d9 100644
--- a/louloulibs/network/tcp_client_socket_handler.cpp
+++ b/louloulibs/network/tcp_client_socket_handler.cpp
@@ -35,7 +35,11 @@ void TCPClientSocketHandler::init_socket(const struct addrinfo* rp)
// Convert the address from string format to a sockaddr that can be
// used in bind()
struct addrinfo* result;
- int err = ::getaddrinfo(this->bind_addr.data(), nullptr, nullptr, &result);
+ struct addrinfo hints;
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_flags = AI_NUMERICHOST;
+ hints.ai_family = AF_UNSPEC;
+ int err = ::getaddrinfo(this->bind_addr.data(), nullptr, &hints, &result);
if (err != 0 || !result)
log_error("Failed to bind socket to ", this->bind_addr, ": ",
gai_strerror(err));