Skip to content

Commit

Permalink
Add support for udp exclusiveAddressUse. (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
wj8400684 authored May 4, 2024
1 parent 1ceb094 commit 97db28c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/SuperSocket.Server.Abstractions/ListenOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/SuperSocket.Udp/UdpConnectionListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 97db28c

Please sign in to comment.