异步SOCKET套接字的连接状态
Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
uint dummy = 0;
byte[] inOptionValues = new byte[Marshal.SizeOf(dummy) * 3];
BitConverter.GetBytes((uint)1).CopyTo(inOptionValues, 0);
BitConverter.GetBytes((uint)5000).CopyTo(inOptionValues, Marshal.SizeOf(dummy));
BitConverter.GetBytes((uint)5000).CopyTo(inOptionValues, Marshal.SizeOf(dummy) * 2);
client.IOControl(IOControlCode.KeepAliveValues, inOptionValues, null);
上边是我网上找的检测套接字状态的方法,目的是从套接字建立后5秒开始每5秒判断一下套接字的连接状态。但我跟踪调试发现没起作用,初始化时从false变为true后就再也不变化了。。。。。请各位大大为小弟解惑!Looking forword!
------解决方案--------------------换方法吧 我曾经也这样检测过 确实一直是true