Skip to content

A helper for connecting Sockets to endpoints in a round-robin fashion

License

Notifications You must be signed in to change notification settings

MihaZupan/DnsRoundRobin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DnsRoundRobin NuGet

A helper for connecting Sockets to endpoints in a round-robin fashion.

var handler = new SocketsHttpHandler
{
    ConnectCallback = async (context, cancellation) =>
    {
        Socket socket = await DnsRoundRobinConnector.Shared.ConnectAsync(context.DnsEndPoint, cancellation);

        return new NetworkStream(socket, ownsSocket: true);
    }
};

You can configure things like the dns refresh interval or per-endpoint connection timeouts.

private static readonly DnsRoundRobinConnector s_roundRobinConnector = new(
    dnsRefreshInterval: TimeSpan.FromSeconds(10),
    endpointConnectTimeout: TimeSpan.FromSeconds(5));

About

A helper for connecting Sockets to endpoints in a round-robin fashion

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages