summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-02-28 23:34:11 +0100
committerlouiz’ <louiz@louiz.org>2017-02-28 23:34:11 +0100
commitfa3d44e7aaf43487f8fed62c9398ade6fa797acb (patch)
tree3a8e4d91787e5d26a98d1ca47d372a98beef7c17
parent73915e889db80ae2950d9845e4158514f1e95dd5 (diff)
downloadbiboumi-fa3d44e7aaf43487f8fed62c9398ade6fa797acb.tar.gz
biboumi-fa3d44e7aaf43487f8fed62c9398ade6fa797acb.tar.bz2
biboumi-fa3d44e7aaf43487f8fed62c9398ade6fa797acb.tar.xz
biboumi-fa3d44e7aaf43487f8fed62c9398ade6fa797acb.zip
Use AI_NUMERICHOST when using getaddrinfo to bind() our client sockets
-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));