-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
46 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
// Copyright (c) Ikpil Choi [email protected] All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Linq; | ||
|
||
namespace UniNetty.Transport.Tests.Channel.Sockets | ||
{ | ||
using System; | ||
|
@@ -106,6 +108,7 @@ public void Multicast(AddressFamily addressFamily, IByteBufferAllocator allocato | |
var serverGroup = new MultithreadEventLoopGroup(1); | ||
var clientGroup = new MultithreadEventLoopGroup(1); | ||
|
||
var supportsMulticast = NetUtil.SupportsMulticastInterface(addressFamily); | ||
try | ||
{ | ||
var multicastHandler = new MulticastTestHandler(); | ||
|
@@ -121,9 +124,11 @@ public void Multicast(AddressFamily addressFamily, IByteBufferAllocator allocato | |
channel.Pipeline.AddLast(nameof(SocketDatagramChannelMulticastTest), multicastHandler); | ||
})); | ||
|
||
IPAddress address = addressFamily == AddressFamily.InterNetwork | ||
? IPAddress.Any | ||
: IPAddress.IPv6Any; | ||
var address = supportsMulticast | ||
.GetIPProperties() | ||
.UnicastAddresses | ||
.First(x => x.Address.AddressFamily == addressFamily) | ||
.Address; | ||
|
||
this.Output.WriteLine($"Multicast server binding to:({addressFamily}){address}"); | ||
Task<IChannel> task = serverBootstrap.BindAsync(address, IPEndPoint.MinPort); | ||
|
@@ -155,8 +160,8 @@ public void Multicast(AddressFamily addressFamily, IByteBufferAllocator allocato | |
|
||
IPAddress multicastAddress = addressFamily == AddressFamily.InterNetwork | ||
? NetUtil.MULTICAST_IPV4 | ||
: NetUtil.MULTICAST_IPV6_SITELOCAL; | ||
: NetUtil.MULTICAST_IPV6_INTERFACE_LOCAL; | ||
|
||
var groupAddress = new IPEndPoint(multicastAddress, serverEndPoint.Port); | ||
Task joinTask = serverChannel.JoinGroup(groupAddress); | ||
Assert.True(joinTask.Wait(TimeSpan.FromMilliseconds(DefaultTimeOutInMilliseconds * 5)), | ||
|