public void RecieveCallback(IAsyncResult ar) { ClientHandler client = (ClientHandler)ar.AsyncState; byte[] receivedData = client.Recieve(ar); if (receivedData.Length < 1) { // Client has disconnected. client._timeDisconnect = DateTime.Now.ToString(); client._clientSocket.Close(); Clients.Remove(client); return; } try { client.SDRTC(); } catch (Exception e) { MessageBox.Show("Can't associate with remote host " + client._clientSocket.RemoteEndPoint.ToString() + "!\nMore details:\n" + e.ToString()); // Send failure. Maybe client has disconnected, or something else. client._timeDisconnect = DateTime.Now.ToString(); client._clientSocket.Close(); Clients.Remove(client); } client.RecieveCallback(this); }