Browse Source

Added a method to DatagramSocket to set whether multicast loopback should be enabled

tags/2021-05-28
ed 7 years ago
parent
commit
ea23ddd69e
2 changed files with 16 additions and 2 deletions
  1. +8
    -0
      modules/juce_core/network/juce_Socket.cpp
  2. +8
    -2
      modules/juce_core/network/juce_Socket.h

+ 8
- 0
modules/juce_core/network/juce_Socket.cpp View File

@@ -741,6 +741,14 @@ bool DatagramSocket::leaveMulticast (const String& multicastIPAddress)
return SocketHelpers::multicast (handle, multicastIPAddress, lastBindAddress, false); return SocketHelpers::multicast (handle, multicastIPAddress, lastBindAddress, false);
} }
bool DatagramSocket::setMulticastLoopbackEnabled (bool enable)
{
if (! isBound || handle < 0)
return false;
return SocketHelpers::setOption<bool> (handle, IPPROTO_IP, IP_MULTICAST_LOOP, enable);
}
bool DatagramSocket::setEnablePortReuse (bool enabled) bool DatagramSocket::setEnablePortReuse (bool enabled)
{ {
#if JUCE_ANDROID #if JUCE_ANDROID


+ 8
- 2
modules/juce_core/network/juce_Socket.h View File

@@ -315,18 +315,24 @@ public:
void shutdown(); void shutdown();
//============================================================================== //==============================================================================
/** Join a multicast group
/** Join a multicast group.
@returns true if it succeeds. @returns true if it succeeds.
*/ */
bool joinMulticast (const String& multicastIPAddress); bool joinMulticast (const String& multicastIPAddress);
/** Leave a multicast group
/** Leave a multicast group.
@returns true if it succeeds. @returns true if it succeeds.
*/ */
bool leaveMulticast (const String& multicastIPAddress); 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. /** Allow other applications to re-use the port.


Loading…
Cancel
Save