现在有服务器和客户端的程序, 现在服务器
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 是否进行了多次连接呢?
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 是否进行了多次连接呢?
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.