Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7905651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:33:45+00:00 2026-06-03T10:33:45+00:00

So here is an application which tests each server of popular RuneScape game. I

  • 0

So here is an application which tests each server of popular RuneScape game. I am running ping on each of 139 servers and add lag value to array. While looping through list entries I can calculate the average, minimum, and maximum lag for each server.

Now, in my code when one of the unreachable servers is noted the lowest lag displays as 0. I’m not sure how to handle if my ping response has reached it’s timeout and posts 0 to array list.

What can I do to avoid that 0 as my lowest ping when server is down?

using System;
using System.Net.NetworkInformation;
using System.Collections.Generic;

namespace RuneScape_Ping_Tool
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write(Environment.NewLine + "Start the test? (y/n): ");

            if (Console.Read() == char.Parse("y"))
            {
                Console.WriteLine();
                Ping();
            }
        }

        static void Ping()
        {
            List<int> lag = new List<int>();

            for (int server = 1; server <= 139; server++)
            {
                string url = "world" + server.ToString() + ".runescape.com";

                Console.WriteLine("Checking world " + server + "...");

                Ping ping = new Ping();
                PingReply reply = ping.Send(url);

                lag.Add(int.Parse(reply.RoundtripTime.ToString()));
            }

            for (int i = 1; i <= 139; i++)
            {
                Console.WriteLine("World " + i + ": " + lag[i - 1]);
            }

            int average = 0;
            int highest = 1;
            int lowest = 1000;

            int highestWorld = 0;
            int lowestWorld = 0;

            for (int i = 1; i <= 139; i++)
            {
                average = average + lag[i - 1];
            }

            for (int i = 1; i <= 139; i++)
            {
                if (highest < lag[i - 1])
                {
                    highest = lag[i - 1];
                    highestWorld = i;
                }
            }

            for (int i = 1; i <= 139; i++)
            {
                if (lowest > lag[i - 1])
                {
                    lowest = lag[i - 1];
                    lowestWorld = i;
                }
            }

            Console.WriteLine();
            Console.WriteLine("Average lag: " + average / 139);
            Console.WriteLine("Highest lag: " + highest + " in world " + highestWorld);
            Console.WriteLine("Lowest lag: " + lowest + " in world " + lowestWorld);

            Console.Write(Environment.NewLine + "Start the test? (y/n): ");

            if (Console.Read() == char.Parse("y"))
            {
                Console.WriteLine();
                Ping();
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T10:33:46+00:00Added an answer on June 3, 2026 at 10:33 am

    Can you just skip over zeroes? Also, you might as well put all the calculations inside a single loop.

    int n = 0 // number of data points
    
    for (int i = 0; i < 139; ++i) {
      if (lag[i] == 0) {
        continue;  // skip 0 values
      }
      ++n;
      sum += lag[i];
    
      if (highest < lag[i]) {
        highest = lag[i];
        highestWorld = i + 1;
      }
    
      if (lowest > lag[i]) {
        lowest = lag[i];
        lowestWorld = i + 1;
      }
    
      average = sum / n;  // Note: you may want to round this.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am Developing an application which consists of video-view,Here is my problem when I
I'm looking for some opinions here, I'm building a web application which has the
To test my server/client application, where each client is known by its IP address,
hi i am doing one application here i need to disply 6 images in
I have a Jsfiddle application here . If you type in a question in
I've downloaded a sample application sending email silverlight application here. via gmail. But I
From My Previous question sending request to apple - from iphone custom application Here,
...before everything, I'm doing this out of curiosity only. Nothing real-world application here, but
This is to create a greeting card application and here i have to change
I'm currently using the validation code listed here in an application. I'd like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.