public void StopClient(NetworkStream stream) { foreach (KeyValuePair<NetworkStream, TcpClient> pair in clientlist) { if (stream.Equals(pair.Key)) { pair.Key.Close(); pair.Value.Close(); } } }