现在有服务器和客户端的程序, 现在服务器
try
{
serverListener = new TcpListener(8802);
serverListener.Start();
do
{
Client newClient = new Client(serverListener.AcceptTcpClient());

newClient.Disconnected+= new DisconnectDelegate(OnDisconnected);
newClient.Connected+=new ConnectDelegate(this.OnConnected);
newClient.MessageReceived+=new MessageDelegate(OnMessageReceived); newClient.Connect();
}
while(true);
}
catch
{
serverListener.Stop();
}请为我怎么判断客户端 是否已经断开了连接。 同一个IP 是否进行了多次连接呢?

解决方案 »

  1.   

    可以使用TCP协议,与指定的服务器是否能建立Scoket连接来判断
      

  2.   

    Thinking(c#)    QQ群6026787.    欢迎大家加入.  验证码:csdn.
      

  3.   

    我也在找这个问题的答案,MSDN上是这样说的。这个Pending方法,我没有测试。Res
    AcceptTcpClient is a blocking method that returns a TcpClient you can use to send and receive data. Use the Pending method to determine if connections requests are available in the incoming connection queue if you want to avoid blocking.
      

  4.   

    发送心跳消息来确认连接状态可以用一个ArrayList来记录所有连接中的IP,用ArrayList.Contains方法就可以判断此IP是否已经处于连接状态