diff --git a/src/SuperSocket.Server.Abstractions/ListenOptions.cs b/src/SuperSocket.Server.Abstractions/ListenOptions.cs index d87b9aa8b..49415a960 100644 --- a/src/SuperSocket.Server.Abstractions/ListenOptions.cs +++ b/src/SuperSocket.Server.Abstractions/ListenOptions.cs @@ -21,7 +21,9 @@ public class ListenOptions public CertificateOptions CertificateOptions { get; set; } public TimeSpan ConnectionAcceptTimeOut { get; set; } = TimeSpan.FromSeconds(5); - + + public bool UdpExclusiveAddressUse { get; set; } = true; + public IPEndPoint ToEndPoint() { var ip = this.Ip; diff --git a/src/SuperSocket.Udp/UdpConnectionListener.cs b/src/SuperSocket.Udp/UdpConnectionListener.cs index 85cc46266..1a62fca49 100644 --- a/src/SuperSocket.Udp/UdpConnectionListener.cs +++ b/src/SuperSocket.Udp/UdpConnectionListener.cs @@ -61,7 +61,8 @@ public bool Start() if (options.NoDelay) listenSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, true); - + + listenSocket.ExclusiveAddressUse = options.UdpExclusiveAddressUse; listenSocket.Bind(listenEndpoint); _acceptRemoteEndPoint = listenEndpoint.AddressFamily == AddressFamily.InterNetworkV6 ? new IPEndPoint(IPAddress.IPv6Any, 0) : new IPEndPoint(IPAddress.Any, 0);