MCPcopy Create free account
hub / github.com/defold/defold / SetMulticastIf

Function SetMulticastIf

engine/dlib/src/dlib/socket_win32.cpp:326–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324 }
325
326 Result SetMulticastIf(Socket socket, Address address)
327 {
328 int result = -1;
329 if (IsSocketIPv4(socket))
330 {
331 struct in_addr inaddr;
332 memset(&inaddr, 0, sizeof(inaddr));
333 inaddr.s_addr = *IPv4(&address);
334 result = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_IF, (char*)&inaddr, sizeof(inaddr));
335 }
336#if !defined(DM_IPV6_UNSUPPORTED)
337 else if (IsSocketIPv6(socket))
338 {
339 struct in6_addr inaddr;
340 memcpy(&inaddr, IPv6(&address), sizeof(struct in6_addr));
341 result = setsockopt(socket, IPPROTO_IP, IP_MULTICAST_IF, (char*)&inaddr, sizeof(inaddr));
342 }
343#endif // no ipv6
344 else
345 {
346 dmLogError("Failed to enable multicast interface, unsupported address family!");
347 return RESULT_AFNOSUPPORT;
348 }
349
350 return result == 0 ? RESULT_OK : NATIVETORESULT(DM_SOCKET_ERRNO);
351 }

Callers 2

SendPacketOnInterfaceFunction · 0.70
TYPED_TESTFunction · 0.50

Calls 2

IPv4Function · 0.85
IsSocketIPv4Function · 0.70

Tested by 1

TYPED_TESTFunction · 0.40