MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / enableMulticast

Method enableMulticast

Engine/source/platform/platformNet.cpp:1865–1958  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1863}
1864
1865void Net::enableMulticast()
1866{
1867 SOCKET socketFd;
1868
1869 if (Net::smIpv6Enabled)
1870 {
1871 socketFd = PlatformNetState::smReservedSocketList.resolve(PlatformNetState::udp6Socket);
1872
1873 if (socketFd != InvalidSocketHandle)
1874 {
1875 PlatformNetState::multicast6Socket = PlatformNetState::udp6Socket;
1876
1877 Net::Error error = NoError;
1878
1879 if (error == NoError)
1880 {
1881 unsigned long multicastTTL = 1;
1882
1883 if (setsockopt(socketFd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
1884 (char*)&multicastTTL, sizeof(multicastTTL)) < 0)
1885 {
1886 error = PlatformNetState::getLastError();
1887 }
1888 }
1889
1890 // Find multicast to bind to...
1891
1892 NetAddress multicastAddress;
1893 sockaddr_in6 multicastSocketAddress;
1894
1895 const char *multicastAddressValue = Con::getVariable("pref::Net::Multicast6Address");
1896 if (!multicastAddressValue || multicastAddressValue[0] == '\0')
1897 {
1898 multicastAddressValue = TORQUE_NET_DEFAULT_MULTICAST_ADDRESS;
1899 }
1900
1901 error = Net::stringToAddress(multicastAddressValue, &multicastAddress, false);
1902
1903 if (error == NoError)
1904 {
1905 dMemset(&PlatformNetState::multicast6Group, '\0', sizeof(&PlatformNetState::multicast6Group));
1906 NetAddressToIPSocket6(&multicastAddress, &multicastSocketAddress);
1907 dMemcpy(&PlatformNetState::multicast6Group.ipv6mr_multiaddr, &multicastSocketAddress.sin6_addr, sizeof(PlatformNetState::multicast6Group.ipv6mr_multiaddr));
1908 }
1909
1910 // Setup group
1911
1912 if (error == NoError)
1913 {
1914 const char *multicastInterface = Con::getVariable("pref::Net::Multicast6Interface");
1915
1916 if (multicastInterface && multicastInterface[0] != '\0')
1917 {
1918#ifdef TORQUE_USE_WINSOCK
1919 PlatformNetState::multicast6Group.ipv6mr_interface = dAtoi(multicastInterface);
1920#else
1921 PlatformNetState::multicast6Group.ipv6mr_interface = if_nametoindex(multicastInterface);
1922#endif

Callers

nothing calls this directly

Calls 8

getLastErrorFunction · 0.85
getVariableFunction · 0.85
NetAddressToIPSocket6Function · 0.85
dAtoiFunction · 0.85
printfFunction · 0.85
dMemsetFunction · 0.50
dMemcpyFunction · 0.50
resolveMethod · 0.45

Tested by

no test coverage detected