1.初始化项目。保险起见bin目录完整提交 2.基于现场代码为调整过的初始项目(此次提交还未解决代码差异问题)
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace AGVSystem.Cls
|
||||
{
|
||||
// Token: 0x0200002E RID: 46
|
||||
public static class SocketExtensions
|
||||
{
|
||||
// Token: 0x06000289 RID: 649 RVA: 0x00053698 File Offset: 0x00051898
|
||||
public static bool SetKeepAlive(this Socket socket, ulong time, ulong interval)
|
||||
{
|
||||
try
|
||||
{
|
||||
ulong[] array = new ulong[]
|
||||
{
|
||||
(time == 0UL || interval == 0UL) ? 0UL : 1UL,
|
||||
time,
|
||||
interval
|
||||
};
|
||||
byte[] array2 = new byte[12];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
array2[i * 4 + 3] = (byte)(array[i] >> 24 & 255UL);
|
||||
array2[i * 4 + 2] = (byte)(array[i] >> 16 & 255UL);
|
||||
array2[i * 4 + 1] = (byte)(array[i] >> 8 & 255UL);
|
||||
array2[i * 4] = (byte)(array[i] & 255UL);
|
||||
}
|
||||
byte[] bytes = BitConverter.GetBytes(0);
|
||||
socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.KeepAlive, true);
|
||||
socket.IOControl((IOControlCode)((ulong)-1744830460), array2, bytes);
|
||||
}
|
||||
catch (SocketException ex)
|
||||
{
|
||||
Console.WriteLine("Failed to set keep-alive: {0} {1}", ex.ErrorCode, ex);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x04000663 RID: 1635
|
||||
private const int BytesPerLong = 4;
|
||||
|
||||
// Token: 0x04000664 RID: 1636
|
||||
private const int BitsPerByte = 8;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user