From 540694df1fb3694457e6573dfb7a1fb01a146164 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 25 May 2020 23:28:47 +0200 Subject: [PATCH] Socket::UDPConnection now uses its currently bound socket type for destinations --- lib/socket.cpp | 2 +- lib/socket.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/socket.cpp b/lib/socket.cpp index 420ae87b..3e8244da 100644 --- a/lib/socket.cpp +++ b/lib/socket.cpp @@ -1685,7 +1685,7 @@ void Socket::UDPConnection::SetDestination(std::string destIp, uint32_t port){ ss << port; memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; + hints.ai_family = family; hints.ai_socktype = SOCK_DGRAM; hints.ai_flags = AI_ADDRCONFIG | AI_V4MAPPED; hints.ai_protocol = IPPROTO_UDP; diff --git a/lib/socket.h b/lib/socket.h index 108357c0..d5935f77 100644 --- a/lib/socket.h +++ b/lib/socket.h @@ -212,6 +212,8 @@ namespace Socket{ void setBlocking(bool blocking); void SetDestination(std::string hostname, uint32_t port); void GetDestination(std::string &hostname, uint32_t &port); + const void * getDestAddr(){return destAddr;} + size_t getDestAddrLen(){return destAddr_size;} std::string getBoundAddress(); uint32_t getDestPort() const; bool Receive();