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 469703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:48:39+00:00 2026-05-12T23:48:39+00:00

Given a range of IP addresses entered by a user (through various means), I

  • 0

Given a range of IP addresses entered by a user (through various means), I want to identify which of these machines have software running that I can talk to.

Here’s the basic process:

  1. Ping these addresses to find available machines

  2. Connect to a known socket on the available machines

  3. Send a message to the successfully established sockets

  4. Compare the response to the expected response

Steps 2-4 are straight forward for me. What is the best way to implement the first step in .NET?

I’m looking at the System.Net.NetworkInformation.Ping class. Should I ping multiple addresses simultaneously to speed up the process? If I ping one address at a time with a long timeout it could take forever. But with a small timeout, I may miss some machines that are available.

Sometimes pings appear to be failing even when I know that the address points to an active machine. Do I need to ping twice in the event of the request getting discarded?

To top it all off, when I scan large collections of addresses with the network cable unplugged, Ping throws a NullReferenceException in FreeUnmanagedResources(). !?

Any pointers on the best approach to scanning a range of IPs like this?

  • 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-05-12T23:48:40+00:00Added an answer on May 12, 2026 at 11:48 pm

    Since not all machines respond to pings (depending on firewall settings) I suggest skipping step 1 if possible.

    If you know the machines you will be connecting to respond to pings the ping class works well enough. It only sends 1 packet so ping more than once in case it gets dropped. Also, in my experience the ping class will often throw an exception instead of returning a PingReply object if the host is unreachable.

    This is my suggested implementation:

    public bool
       Ping (string host, int attempts, int timeout)
       {
          System.Net.NetworkInformation.Ping  ping = 
                                           new System.Net.NetworkInformation.Ping ();
    
          System.Net.NetworkInformation.PingReply  pingReply;
    
          for (int i = 0; i < attempts; i++)
          {
             try
             {
                pingReply = ping.Send (host, timeout); 
    
                // If there is a successful ping then return true.
                if (pingReply != null &&
                    pingReply.Status == System.Net.NetworkInformation.IPStatus.Success)
                   return true;
             }
             catch
             {
                // Do nothing and let it try again until the attempts are exausted.
                // Exceptions are thrown for normal ping failurs like address lookup
                // failed.  For this reason we are supressing errors.
             }
          }
    
          // Return false if we can't successfully ping the server after several attempts.
          return false;
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I create a named range through the Name Manager, I'm given the option
Win-XP, Excel 2003 I have a range defined by a name, which is filled
I want to create a custom malloc which allocates memory blocks within a given
I have a CVS database which gives a V6 range 2001:1800::/32 and a country
Trouble! I'm looking for a way to find the countries within a given range
Given a Range of numbers say 1 to 10,000, Input is in random order.
I'm trying to calculate time blocks from given date range. Here's my attempt: <?php
Given a date range how to calculate the number of weekends partially or wholly
So in Java, whenever an indexed range is given, the upper bound is almost
You are given 2^32-2 unique numbers that range from 1 to 2^32-1. It's impossible

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.