我在客户端有关tcpclient连接的问题...
如何立即获得真实的连接状态并在需要时重新连接?
我尝试过一些例子,但他们总是回复'真实'.....但实际上已经断开了。
1.return TcpClient.Connected
2.return TcpClient.Client.Connected
3.return!(socket.Poll(1,SelectMode.SelectRead)&& socket.Available == 0);
bool notclosed = true; byte [] testByte = new byte [1];
if(socket.Connected&&& socket.Poll(0,SelectMode.SelectRead)) closed =(socket.Receive(testByte,SocketFlags.Peek)== 0);
返回未关闭;