summaryrefslogtreecommitdiff
path: root/csharp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2015-05-13 09:51:03 +0200
committerBenoit Foucher <benoit@zeroc.com>2015-05-13 09:51:03 +0200
commitec7e37c8cd71848f3db047de74f66aae63ff9bbe (patch)
tree52c9831a9c67e86799662e4c79b912183faa3a09 /csharp/src
parentFixed ICE-6498: replaced protocol error with encoding error un UnsupportedEnc... (diff)
downloadice-ec7e37c8cd71848f3db047de74f66aae63ff9bbe.tar.bz2
ice-ec7e37c8cd71848f3db047de74f66aae63ff9bbe.tar.xz
ice-ec7e37c8cd71848f3db047de74f66aae63ff9bbe.zip
Fixed ICE-6499: set default interface for sending UDP multicast datagrams
Diffstat (limited to 'csharp/src')
-rw-r--r--csharp/src/Ice/Network.cs35
-rw-r--r--csharp/src/Ice/UdpTransceiver.cs18
2 files changed, 46 insertions, 7 deletions
diff --git a/csharp/src/Ice/Network.cs b/csharp/src/Ice/Network.cs
index 413679340a4..199dae9b8c0 100644
--- a/csharp/src/Ice/Network.cs
+++ b/csharp/src/Ice/Network.cs
@@ -532,6 +532,41 @@ namespace IceInternal
}
}
+ public static void setMcastInterface(Socket socket, string iface, AddressFamily family)
+ {
+ try
+ {
+ int ifaceIndex = getInterfaceIndex(iface, family);
+ if(ifaceIndex == -1)
+ {
+ try
+ {
+ ifaceIndex = System.Int32.Parse(iface, CultureInfo.InvariantCulture);
+ }
+ catch(System.FormatException ex)
+ {
+ closeSocketNoThrow(socket);
+ throw new Ice.SocketException(ex);
+ }
+ }
+
+ if(family == AddressFamily.InterNetwork)
+ {
+ ifaceIndex = (int)IPAddress.HostToNetworkOrder(ifaceIndex);
+ socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastInterface, ifaceIndex);
+ }
+ else
+ {
+ socket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.MulticastInterface, ifaceIndex);
+ }
+ }
+ catch(SocketException ex)
+ {
+ closeSocketNoThrow(socket);
+ throw new Ice.SocketException(ex);
+ }
+ }
+
public static void setMcastGroup(Socket s, IPAddress group, string iface)
{
try
diff --git a/csharp/src/Ice/UdpTransceiver.cs b/csharp/src/Ice/UdpTransceiver.cs
index e9a7531340a..1c01c135ae6 100644
--- a/csharp/src/Ice/UdpTransceiver.cs
+++ b/csharp/src/Ice/UdpTransceiver.cs
@@ -868,15 +868,19 @@ namespace IceInternal
setBufSize(-1, -1);
#if !SILVERLIGHT
Network.setBlock(_fd, false);
- if(AssemblyUtil.osx_)
+ if(Network.isMulticast((IPEndPoint)_addr))
{
- //
- // On Windows, we delay the join for the mcast group after the connection
- // establishment succeeds. This is necessary for older Windows versions
- // where joining the group fails if the socket isn't bound. See ICE-5113.
- //
- if(Network.isMulticast((IPEndPoint)_addr))
+ if(_mcastInterface.Length > 0)
+ {
+ Network.setMcastInterface(_fd, _mcastInterface, _addr.AddressFamily);
+ }
+ if(AssemblyUtil.osx_)
{
+ //
+ // On Windows, we delay the join for the mcast group after the connection
+ // establishment succeeds. This is necessary for older Windows versions
+ // where joining the group fails if the socket isn't bound. See ICE-5113.
+ //
Network.setMcastGroup(_fd, ((IPEndPoint)_addr).Address, _mcastInterface);
if(_mcastTtl != -1)
{