diff options
Diffstat (limited to 'csharp/src/Ice/Network.cs')
-rw-r--r-- | csharp/src/Ice/Network.cs | 35 |
1 files changed, 35 insertions, 0 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 |