Skip to content

Commit

Permalink
Convert keep-alive time/interval to ms for IOControl (#153 closes #152)
Browse files Browse the repository at this point in the history
  • Loading branch information
luigiberrettini committed Oct 28, 2018
1 parent 24f3509 commit 6bdd181
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/NLog.Targets.Syslog/MessageSend/IOControlKeepAliveValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ internal class IOControlKeepAliveValues
private readonly int intervalOffset;
private readonly int structSize;
private readonly uint onOff;
private readonly uint time;
private readonly uint interval;
private readonly uint timeMs;
private readonly uint intervalMs;

public IOControlKeepAliveValues(KeepAliveConfig keepAliveConfig)
{
Expand All @@ -33,16 +33,16 @@ public IOControlKeepAliveValues(KeepAliveConfig keepAliveConfig)
intervalOffset = 2 * uintSize;
structSize = 3 * uintSize;
onOff = (uint)(keepAliveConfig.Enabled ? 1 : 0);
time = (uint)keepAliveConfig.Time;
interval = (uint)keepAliveConfig.Interval;
timeMs = (uint)keepAliveConfig.Time * 1000;
intervalMs = (uint)keepAliveConfig.Interval * 1000;
}

public byte[] ToByteArray()
{
var keepAliveSettings = new byte[structSize];
BitConverter.GetBytes(onOff).CopyTo(keepAliveSettings, onOffOffset);
BitConverter.GetBytes(time).CopyTo(keepAliveSettings, timeOffset);
BitConverter.GetBytes(interval).CopyTo(keepAliveSettings, intervalOffset);
BitConverter.GetBytes(timeMs).CopyTo(keepAliveSettings, timeOffset);
BitConverter.GetBytes(intervalMs).CopyTo(keepAliveSettings, intervalOffset);
return keepAliveSettings;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ internal class SocketInitializationForWindows : SocketInitialization
// Retry count:
// - 5 or min(255, max(TcpMaxDataRetransmissions, PPTPTcpMaxDataRetransmissions)) on Win 2000, Win XP and Win Server 2003
// - 10 on Win Vista and later and value cannot be changed before Windows 10 version 1703
// 2 hours
// 1 second
// Time: 2 hours
// Interval: 1 second

private const SocketOptionName TcpKeepAliveRetryCount = (SocketOptionName)0x10;
private const SocketOptionName TcpKeepAliveTime = (SocketOptionName)0x3;
Expand Down

0 comments on commit 6bdd181

Please sign in to comment.