Socket IOControl
百里行者 2011-06-29 09:43:59 const uint KEEPALIVESEC = 10;
Socket socketbase = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
uint dummy = 0;
int size = System.Runtime.InteropServices.Marshal.SizeOf(dummy);
byte[] options = new byte[size * 3];
BitConverter.GetBytes((uint)1).CopyTo(options, 0);
BitConverter.GetBytes(KEEPALIVESEC * 1000).CopyTo(options, size);
BitConverter.GetBytes(KEEPALIVESEC * 1000).CopyTo(options, size * 2);
int x = BitConverter.ToInt32(options, 0);
socketbase.IOControl(IOControlCode.KeepAliveValues, options, null);
这里的options长度是12,说是“操作要求的输入数据”
BitConverter.GetBytes((uint)1)=1,0,0,0
BitConverter.GetBytes(KEEPALIVESEC * 1000)=16,39,0,0
高手来说说,这个options,还有最后一个参数,到底干吗用的?