Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Multicast on machines with multiple network interfaces #1185

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions modules/juce_core/network/juce_Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,14 @@ bool DatagramSocket::joinMulticast (const String& multicastIPAddress)

return SocketHelpers::multicast (handle, multicastIPAddress, lastBindAddress, true);
}

bool DatagramSocket::joinMulticast (const String& multicastIPAddress, const String& localIPAddress)
{
if (handle < 0 || ! isBound)
return false;

return SocketHelpers::multicast (handle, multicastIPAddress, localIPAddress, true);
}

bool DatagramSocket::leaveMulticast (const String& multicastIPAddress)
{
Expand All @@ -805,6 +813,14 @@ bool DatagramSocket::leaveMulticast (const String& multicastIPAddress)

return SocketHelpers::multicast (handle, multicastIPAddress, lastBindAddress, false);
}

bool DatagramSocket::leaveMulticast (const String& multicastIPAddress, const String& localIPAddress)
{
if (handle < 0 || ! isBound)
return false;

return SocketHelpers::multicast (handle, multicastIPAddress, localIPAddress, false);
}

bool DatagramSocket::setMulticastLoopbackEnabled (bool enable)
{
Expand Down
4 changes: 4 additions & 0 deletions modules/juce_core/network/juce_Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,16 @@ class JUCE_API DatagramSocket final
@returns true if it succeeds
*/
bool joinMulticast (const String& multicastIPAddress);

bool joinMulticast (const String& multicastIPAddress, const String& localIPAddress);

/** Leave a multicast group.

@returns true if it succeeds
*/
bool leaveMulticast (const String& multicastIPAddress);

bool leaveMulticast (const String& multicastIPAddress, const String& localIPAddress);

/** Enables or disables multicast loopback.

Expand Down
Loading