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

Method enableMulticast

Engine/source/platform/platformNet.cpp:1914–2008  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1912}
1913
1914void Net::enableMulticast()
1915{
1916 SOCKET socketFd;
1917
1918 if (Net::smIpv6Enabled)
1919 {
1920 socketFd = PlatformNetState::smReservedSocketList.resolve(PlatformNetState::udp6Socket);
1921
1922 if (socketFd != InvalidSocketHandle)
1923 {
1924 PlatformNetState::multicast6Socket = PlatformNetState::udp6Socket;
1925
1926 Net::Error error = NoError;
1927
1928 if (error == NoError)
1929 {
1930 unsigned long multicastTTL = 1;
1931
1932 if (setsockopt(socketFd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
1933 (char*)&multicastTTL, sizeof(multicastTTL)) < 0)
1934 {
1935 error = PlatformNetState::getLastError();
1936 }
1937 }
1938
1939 // Find multicast to bind to...
1940
1941 NetAddress multicastAddress;
1942 sockaddr_in6 multicastSocketAddress;
1943
1944 const char *multicastAddressValue = Con::getVariable("pref::Net::Multicast6Address");
1945 if (!multicastAddressValue || multicastAddressValue[0] == '\0')
1946 {
1947 multicastAddressValue = TORQUE_NET_DEFAULT_MULTICAST_ADDRESS;
1948 }
1949
1950 error = Net::stringToAddress(multicastAddressValue, &multicastAddress, false);
1951
1952 if (error == NoError)
1953 {
1954 dMemset(&PlatformNetState::multicast6Group, '\0', sizeof(&PlatformNetState::multicast6Group));
1955 NetAddressToIPSocket6(&multicastAddress, &multicastSocketAddress);
1956 dMemcpy(&PlatformNetState::multicast6Group.ipv6mr_multiaddr, &multicastSocketAddress.sin6_addr, sizeof(PlatformNetState::multicast6Group.ipv6mr_multiaddr));
1957 }
1958
1959 // Setup group
1960
1961 if (error == NoError)
1962 {
1963 const char *multicastInterface = Con::getVariable("pref::Net::Multicast6Interface");
1964
1965 if (multicastInterface && multicastInterface[0] != '\0')
1966 {
1967#ifdef TORQUE_USE_WINSOCK
1968 PlatformNetState::multicast6Group.ipv6mr_interface = dAtoi(multicastInterface);
1969#else
1970 PlatformNetState::multicast6Group.ipv6mr_interface = if_nametoindex(multicastInterface);
1971#endif

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected