public static SocketError Set(SafeSocketHandle handle, SocketOptionName optionName, int optionValueSeconds)
{
IOControlKeepAlive ioControlKeepAlive = s_socketKeepAliveTable.GetOrCreateValue(handle);
if (optionName == SocketOptionName.TcpKeepAliveTime)
{
ioControlKeepAlive._timeMs = SecondsToMilliseconds(optionValueSeconds);
}
else
{
ioControlKeepAlive._intervalMs = SecondsToMilliseconds(optionValueSeconds);
}
byte[] buffer = s_keepAliveValuesBuffer ?? (s_keepAliveValuesBuffer = new byte[3 * sizeof(uint)]);
ioControlKeepAlive.Fill(buffer);
int realOptionLength = 0;
return(SocketPal.WindowsIoctl(handle, unchecked ((int)IOControlCode.KeepAliveValues), buffer, null, out realOptionLength));
}