diff --git a/modules/juce_core/network/juce_Socket.cpp b/modules/juce_core/network/juce_Socket.cpp index 1fb520b938..4ffcf49f90 100644 --- a/modules/juce_core/network/juce_Socket.cpp +++ b/modules/juce_core/network/juce_Socket.cpp @@ -741,6 +741,14 @@ bool DatagramSocket::leaveMulticast (const String& multicastIPAddress) return SocketHelpers::multicast (handle, multicastIPAddress, lastBindAddress, false); } +bool DatagramSocket::setMulticastLoopbackEnabled (bool enable) +{ + if (! isBound || handle < 0) + return false; + + return SocketHelpers::setOption (handle, IPPROTO_IP, IP_MULTICAST_LOOP, enable); +} + bool DatagramSocket::setEnablePortReuse (bool enabled) { #if JUCE_ANDROID diff --git a/modules/juce_core/network/juce_Socket.h b/modules/juce_core/network/juce_Socket.h index 1b97325adb..fe689b4fe8 100644 --- a/modules/juce_core/network/juce_Socket.h +++ b/modules/juce_core/network/juce_Socket.h @@ -315,18 +315,24 @@ public: void shutdown(); //============================================================================== - /** Join a multicast group + /** Join a multicast group. @returns true if it succeeds. */ bool joinMulticast (const String& multicastIPAddress); - /** Leave a multicast group + /** Leave a multicast group. @returns true if it succeeds. */ bool leaveMulticast (const String& multicastIPAddress); + /** Enables or disables multicast loopback. + + @returns true if it succeeds. + */ + bool setMulticastLoopbackEnabled (bool enableLoopback); + //============================================================================== /** Allow other applications to re-use the port.