UDP: support not only AF_INET (IPv4) but also AF_INET6 (IPv6) addresses (including link-local) v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 07 Aug 2022 15:09:47 +0200
branchv_0
changeset 19 7a9a52e949b9
parent 18 e16fa75135ad
child 20 ad21bff45051
UDP: support not only AF_INET (IPv4) but also AF_INET6 (IPv6) addresses (including link-local)
src/Socket.cpp
--- a/src/Socket.cpp	Sat Aug 06 15:23:40 2022 +0200
+++ b/src/Socket.cpp	Sun Aug 07 15:09:47 2022 +0200
@@ -153,7 +153,7 @@
 
 	void send(const std::string& message) override {
 		auto ai = remoteAddress.ai;
-		FD s(::socket(AF_INET, ai->ai_socktype, ai->ai_protocol));
+		FD s(::socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol));
 		sendto(s.getFD(), message.c_str(), message.size(), 0, ai->ai_addr, ai->ai_addrlen);
 		if (delay) usleep(delay);
 	}