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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:39:55+00:00 2026-06-03T02:39:55+00:00

I want to check if some email domain exist. When Dns.GetHostEntry(domain) throw an exception

  • 0

I want to check if some email domain exist.

When Dns.GetHostEntry(domain) throw an exception I know for sure that the domain doesn’t exist.

  1. Can I say that if Dns.GetHostEntry(domain) succeeded then the domain does exists or even if Dns.GetHostEntry(domain) succeeded that doesn’t mean (yet) that domain exists?
  2. Can I say the same when s.Connect fails to connect? I mean if connect throw an exception can I say that such domain doesn’t exist?

If (1) is true, so in order to check if domain exists (1) will be enough, right?

public static bool Lookup(string domain)
{
    if (domain == null) throw new ArgumentNullException("domain");

    try {
       IPHostEntry ipHost = Dns.GetHostEntry(domain);
       var endPoint = new IPEndPoint(ipHost.AddressList[0], _dnsPort);

       return Transfer(endPoint);
    }
    catch (SocketException ex)
    {
          ++attempts;
    }
    return false;
}
public static bool Transfer(IPEndPoint endPoint)
{
    int attempts = 0;
    while(attempts <= _attempts)
    {                            
        try
        {
             var s = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
             s.Connect(endPoint);
        }
        catch (SocketException ex)
        {
            ++attempts;
        }
        finally
        {
            s.Close();
        }
    }
}
  • 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-03T02:39:56+00:00Added an answer on June 3, 2026 at 2:39 am

    When trying to connect with a socket you’re saying a few things:

    • There is a network path from my machine to the target machine
    • The network path is clear of firewall and other restrictions
    • The target machine is hosting a service on the target port
    • The target machine is accepting my connections on that target service

    All of these occur after the hostname has been resolved to an IP.

    So the answer to your question is no. If Socket.Connect fails it could be that the domain doesn’t exist, or any of the above reasons (and perhaps more).

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

Sidebar

Related Questions

I want to check that some integer type belongs to (an) enumeration member. For
I want to check some string before sending an email. I have 3 fields:
I want to check some things about the state of the session, the user
I want to check some values in the content of chrome browser page when
Possible Duplicate: Faster DirectoryExists function? I want to check if some file exists on
for some reason I want to check how the deadlock occurred in web application
In javascript I check for some characters but I want to allow underscores and
I want to check if the day is Sunday, but for some reason I
I am writing some new SQL queries and want to check the query plans
I am writing some data access code and I want to check for potentially

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.