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

  • Home
  • SEARCH
  • 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 8694573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:48:58+00:00 2026-06-13T00:48:58+00:00

Recently discovered that using async socket API in C# actually executes the DNS resolve

  • 0

Recently discovered that using async socket API in C# actually executes the DNS resolve on the calling thread, so if there is a problem with the resolve it will hang until timeout.
I would like to find a way to simulate DNS resolve problems without touching the running code so the QA can also use it in tests.

Insentive: Many .NET async API’s like WebRequest, Image (WinForms, WPF) execute the DNS resolution on the calling thread that can result in hangs of the UI.

Example: (what I would like to be able to simulate)
If DNS fails to resolve the code will never reach (1) but an exception will be thrown from EndGetResponse in (2) after some timeout delay.

class Program
{
    static void Main()
    {
        var request = WebRequest.Create("http://www.google.com");
        request.BeginGetResponse(WebRequestCallback, request);
        // (1)
        Console.ReadLine();
    }
    private static void WebRequestCallback(IAsyncResult ar)
    {
        // (2)
        var response = ((WebRequest) ar.AsyncState).EndGetResponse(ar);
    }
}
  • 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-13T00:48:59+00:00Added an answer on June 13, 2026 at 12:48 am

    Thx Hans, excellent idea.
    I will just add the exact steps:

    1. Control panel -> network -> change adapter settings
    2. Double click the connection you use
    3. Properties on the TCP protocol you use
    4. Advanced
    5. DNS tab
    6. Add DNS server IP (*)
    7. Close all network windows
    8. Run: “ipconfig /flushdns”

    (*) It must be IP that can be resolved but doesn’t return DNS reply (google.com is good) because otherwise the DHCP will return response too fast that the address in unresolvable, and if the server exist it should not return response so the timeout will be reached.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've discovered recently that when using the Session or Application objects within an ASP.net
I recently discovered that all Windows 7 machines have an handwriting recognition API within
I recently discovered that attempting to resolve 127localhost.com on (at least OSX Lion) resolves
We regularly setup simple winforms using Linq To Sql. I recently discovered that the
I have recently discovered that I was using my third party diff/merge tool incorrectly
I have recently looked into this and discovered that using FBML pages in a
I'm using libsvm library in my project and have recently discovered that it provides
I recently discovered that when you have a page set to session readonly and
I recently discovered that I can use lambdas to create simple event handlers. I
I recently discovered that a sql query that was running fine earlier is now

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.