aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Common/Extensions.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-11-26 15:51:53 -0600
committerGitHub <noreply@github.com>2021-11-26 15:51:53 -0600
commitf792beb409b4fa8ee1cc8cd74bc314f2556df93d (patch)
tree542b84bcd8ac0ed14bc39da3e80290bce77677f1 /src/slskd/Common/Extensions.cs
parent66ed49ce621e081061b8e8a3b8d97e9cc9f658c7 (diff)
parenteb662b4f198e60d54e278e5ab56ad1f49f4200b0 (diff)
downloadslskd-f792beb409b4fa8ee1cc8cd74bc314f2556df93d.tar.gz
Merge pull request #282 from slskd/keepalive
Configure TCP KeepAlive for server and distributed connections
Diffstat (limited to 'src/slskd/Common/Extensions.cs')
-rw-r--r--src/slskd/Common/Extensions.cs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/slskd/Common/Extensions.cs b/src/slskd/Common/Extensions.cs
index 4d463092..32a9b26e 100644
--- a/src/slskd/Common/Extensions.cs
+++ b/src/slskd/Common/Extensions.cs
@@ -21,10 +21,12 @@ namespace slskd
using System.Collections.Generic;
using System.IO;
using System.Linq;
+ using System.Net.Sockets;
using System.Reflection;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
+ using Soulseek;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
@@ -283,6 +285,36 @@ namespace slskd
}
/// <summary>
+ /// Creates a copy of this instance with the specified parameters changed.
+ /// </summary>
+ /// <param name="o">The options instance to copy.</param>
+ /// <param name="readBufferSize">The read buffer size for underlying TCP connections.</param>
+ /// <param name="writeBufferSize">The write buffer size for underlying TCP connections.</param>
+ /// <param name="writeQueueSize">The size of the write queue for double buffered writes.</param>
+ /// <param name="connectTimeout">The connection timeout, in milliseconds, for client and peer TCP connections.</param>
+ /// <param name="inactivityTimeout">The inactivity timeout, in milliseconds, for peer TCP connections.</param>
+ /// <param name="proxyOptions">Optional SOCKS 5 proxy configuration options.</param>
+ /// <param name="configureSocketAction">
+ /// The delegate invoked during instantiation to configure the server Socket instance.
+ /// </param>
+ /// <returns>The new instance.</returns>
+ public static ConnectionOptions With(
+ this ConnectionOptions o,
+ int? readBufferSize = null,
+ int? writeBufferSize = null,
+ int? writeQueueSize = null,
+ int? connectTimeout = null,
+ int? inactivityTimeout = null,
+ ProxyOptions proxyOptions = null,
+ Action<Socket> configureSocketAction = null) => new ConnectionOptions(
+ readBufferSize: readBufferSize ?? o.ReadBufferSize,
+ writeBufferSize: writeBufferSize ?? o.WriteBufferSize,
+ writeQueueSize: writeQueueSize ?? o.WriteQueueSize,
+ connectTimeout: connectTimeout ?? o.ConnectTimeout,
+ inactivityTimeout: inactivityTimeout ?? o.InactivityTimeout,
+ configureSocketAction: configureSocketAction ?? o.ConfigureSocketAction);
+
+ /// <summary>
/// Deserializes this string from json to an object of type <typeparamref name="T"/>.
/// </summary>
/// <typeparam name="T">The type to which to deserialize the string.</typeparam>