473,782 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

code takes a while to return if error

I have the following code:

Dim IP, domainName As String
domainName = "yahoo.com"

Try
IP = System.Net.Dns. GetHostByName(d omainName).Addr essList(0).ToSt ring()
Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLi ne(IP)
System.Threadin g.Thread.Sleep( 2000)
When it has a resolvable domain, like yahoo.com it responds back instantly
with the ip address. However, if there is a domain in there that does not
exist, like blue2343.com, it takes upwards of 5 seconds to print "Not Valid"
to the screen. Why is that? and is there a way around it?

Thanks,

Scott
Nov 20 '05 #1
22 1560
Scot,

This is mostly likely due to the time it is taking for your DNS server to
attempt to resolve the DNS name to an IP address. It is not uncommon for
3-6 seconds to pass while DNS attempts to resolve an entry that does not
exist. There is no way around the time it takes for a DNS server to exhaust
its resources in an attempt to resolve hostnames to ip addresses.

HTH,

Raymond Lewallen

"Scot" <bl***@blank.bl ank.com> wrote in message
news:c5******** @library1.airne ws.net...
I have the following code:

Dim IP, domainName As String
domainName = "yahoo.com"

Try
IP = System.Net.Dns. GetHostByName(d omainName).Addr essList(0).ToSt ring() Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLi ne(IP)
System.Threadin g.Thread.Sleep( 2000)
When it has a resolvable domain, like yahoo.com it responds back instantly
with the ip address. However, if there is a domain in there that does not
exist, like blue2343.com, it takes upwards of 5 seconds to print "Not Valid" to the screen. Why is that? and is there a way around it?

Thanks,

Scott

Nov 20 '05 #2
Scot,

This is mostly likely due to the time it is taking for your DNS server to
attempt to resolve the DNS name to an IP address. It is not uncommon for
3-6 seconds to pass while DNS attempts to resolve an entry that does not
exist. There is no way around the time it takes for a DNS server to exhaust
its resources in an attempt to resolve hostnames to ip addresses.

HTH,

Raymond Lewallen

"Scot" <bl***@blank.bl ank.com> wrote in message
news:c5******** @library1.airne ws.net...
I have the following code:

Dim IP, domainName As String
domainName = "yahoo.com"

Try
IP = System.Net.Dns. GetHostByName(d omainName).Addr essList(0).ToSt ring() Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLi ne(IP)
System.Threadin g.Thread.Sleep( 2000)
When it has a resolvable domain, like yahoo.com it responds back instantly
with the ip address. However, if there is a domain in there that does not
exist, like blue2343.com, it takes upwards of 5 seconds to print "Not Valid" to the screen. Why is that? and is there a way around it?

Thanks,

Scott

Nov 20 '05 #3
Hi Raymond

I have no doubt that you are correct, however, I had assumed that Scot was
referring to the time it takes to catch and throw an exception.

I have noticed that the first time an exception is thrown and caught, a .NET
application can take a significant time (several seconds) before returning
control to the catch block.

Unfortunately for Scot, I don't know why this should be, so I am watching
this thread with interest in case there is anything I can do about it as
well. It does not seem to matter whether the exception is thrown manually
either; the first time always takes several seconds.

Charles
"Raymond Lewallen" <Ra************ ******@nospam.f aa.gov> wrote in message
news:Oq******** *****@tk2msftng p13.phx.gbl...
Scot,

This is mostly likely due to the time it is taking for your DNS server to
attempt to resolve the DNS name to an IP address. It is not uncommon for
3-6 seconds to pass while DNS attempts to resolve an entry that does not
exist. There is no way around the time it takes for a DNS server to exhaust its resources in an attempt to resolve hostnames to ip addresses.

HTH,

Raymond Lewallen

"Scot" <bl***@blank.bl ank.com> wrote in message
news:c5******** @library1.airne ws.net...
I have the following code:

Dim IP, domainName As String
domainName = "yahoo.com"

Try
IP =

System.Net.Dns. GetHostByName(d omainName).Addr essList(0).ToSt ring()
Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLi ne(IP)
System.Threadin g.Thread.Sleep( 2000)
When it has a resolvable domain, like yahoo.com it responds back instantly with the ip address. However, if there is a domain in there that does not exist, like blue2343.com, it takes upwards of 5 seconds to print "Not

Valid"
to the screen. Why is that? and is there a way around it?

Thanks,

Scott


Nov 20 '05 #4
Hi Raymond

I have no doubt that you are correct, however, I had assumed that Scot was
referring to the time it takes to catch and throw an exception.

I have noticed that the first time an exception is thrown and caught, a .NET
application can take a significant time (several seconds) before returning
control to the catch block.

Unfortunately for Scot, I don't know why this should be, so I am watching
this thread with interest in case there is anything I can do about it as
well. It does not seem to matter whether the exception is thrown manually
either; the first time always takes several seconds.

Charles
"Raymond Lewallen" <Ra************ ******@nospam.f aa.gov> wrote in message
news:Oq******** *****@tk2msftng p13.phx.gbl...
Scot,

This is mostly likely due to the time it is taking for your DNS server to
attempt to resolve the DNS name to an IP address. It is not uncommon for
3-6 seconds to pass while DNS attempts to resolve an entry that does not
exist. There is no way around the time it takes for a DNS server to exhaust its resources in an attempt to resolve hostnames to ip addresses.

HTH,

Raymond Lewallen

"Scot" <bl***@blank.bl ank.com> wrote in message
news:c5******** @library1.airne ws.net...
I have the following code:

Dim IP, domainName As String
domainName = "yahoo.com"

Try
IP =

System.Net.Dns. GetHostByName(d omainName).Addr essList(0).ToSt ring()
Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLi ne(IP)
System.Threadin g.Thread.Sleep( 2000)
When it has a resolvable domain, like yahoo.com it responds back instantly with the ip address. However, if there is a domain in there that does not exist, like blue2343.com, it takes upwards of 5 seconds to print "Not

Valid"
to the screen. Why is that? and is there a way around it?

Thanks,

Scott


Nov 20 '05 #5
Charles, Scot,

Perhaps Scot can step through his code and tell us if the delay is coming
when he steps into the GetHostByName method, or when he steps into the
Catch. Personally, I haven't noticed any delays in .NET code when an
exception is being thrown for the first time. Maybe thats because I'm not
looking for it :)

Raymond Lewallen

"Charles Law" <bl***@nowhere. com> wrote in message
news:el******** ******@tk2msftn gp13.phx.gbl...
Hi Raymond

I have no doubt that you are correct, however, I had assumed that Scot was
referring to the time it takes to catch and throw an exception.

I have noticed that the first time an exception is thrown and caught, a ..NET application can take a significant time (several seconds) before returning
control to the catch block.

Unfortunately for Scot, I don't know why this should be, so I am watching
this thread with interest in case there is anything I can do about it as
well. It does not seem to matter whether the exception is thrown manually
either; the first time always takes several seconds.

Charles
"Raymond Lewallen" <Ra************ ******@nospam.f aa.gov> wrote in message
news:Oq******** *****@tk2msftng p13.phx.gbl...
Scot,

This is mostly likely due to the time it is taking for your DNS server to
attempt to resolve the DNS name to an IP address. It is not uncommon for 3-6 seconds to pass while DNS attempts to resolve an entry that does not
exist. There is no way around the time it takes for a DNS server to

exhaust
its resources in an attempt to resolve hostnames to ip addresses.

HTH,

Raymond Lewallen

"Scot" <bl***@blank.bl ank.com> wrote in message
news:c5******** @library1.airne ws.net...
I have the following code:

Dim IP, domainName As String
domainName = "yahoo.com"

Try
IP =

System.Net.Dns. GetHostByName(d omainName).Addr essList(0).ToSt ring()
Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLi ne(IP)
System.Threadin g.Thread.Sleep( 2000)
When it has a resolvable domain, like yahoo.com it responds back

instantly with the ip address. However, if there is a domain in there that does not exist, like blue2343.com, it takes upwards of 5 seconds to print "Not

Valid"
to the screen. Why is that? and is there a way around it?

Thanks,

Scott



Nov 20 '05 #6
Charles, Scot,

Perhaps Scot can step through his code and tell us if the delay is coming
when he steps into the GetHostByName method, or when he steps into the
Catch. Personally, I haven't noticed any delays in .NET code when an
exception is being thrown for the first time. Maybe thats because I'm not
looking for it :)

Raymond Lewallen

"Charles Law" <bl***@nowhere. com> wrote in message
news:el******** ******@tk2msftn gp13.phx.gbl...
Hi Raymond

I have no doubt that you are correct, however, I had assumed that Scot was
referring to the time it takes to catch and throw an exception.

I have noticed that the first time an exception is thrown and caught, a ..NET application can take a significant time (several seconds) before returning
control to the catch block.

Unfortunately for Scot, I don't know why this should be, so I am watching
this thread with interest in case there is anything I can do about it as
well. It does not seem to matter whether the exception is thrown manually
either; the first time always takes several seconds.

Charles
"Raymond Lewallen" <Ra************ ******@nospam.f aa.gov> wrote in message
news:Oq******** *****@tk2msftng p13.phx.gbl...
Scot,

This is mostly likely due to the time it is taking for your DNS server to
attempt to resolve the DNS name to an IP address. It is not uncommon for 3-6 seconds to pass while DNS attempts to resolve an entry that does not
exist. There is no way around the time it takes for a DNS server to

exhaust
its resources in an attempt to resolve hostnames to ip addresses.

HTH,

Raymond Lewallen

"Scot" <bl***@blank.bl ank.com> wrote in message
news:c5******** @library1.airne ws.net...
I have the following code:

Dim IP, domainName As String
domainName = "yahoo.com"

Try
IP =

System.Net.Dns. GetHostByName(d omainName).Addr essList(0).ToSt ring()
Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLi ne(IP)
System.Threadin g.Thread.Sleep( 2000)
When it has a resolvable domain, like yahoo.com it responds back

instantly with the ip address. However, if there is a domain in there that does not exist, like blue2343.com, it takes upwards of 5 seconds to print "Not

Valid"
to the screen. Why is that? and is there a way around it?

Thanks,

Scott



Nov 20 '05 #7
I think Charles is correct in his assumption. I understand that DNS lookups
on non-existant domains take longer, but not in the 3 to 5 second range. A
second or two would be acceptable, but even that would be long if you there
was minimal network latency.

I believe it is something in the Try..Catch segment. Anyone?
"Raymond Lewallen" <Ra************ ******@nospam.f aa.gov> wrote in message
news:Oq******** *****@tk2msftng p13.phx.gbl...
Scot,

This is mostly likely due to the time it is taking for your DNS server to
attempt to resolve the DNS name to an IP address. It is not uncommon for
3-6 seconds to pass while DNS attempts to resolve an entry that does not
exist. There is no way around the time it takes for a DNS server to exhaust its resources in an attempt to resolve hostnames to ip addresses.

HTH,

Raymond Lewallen

"Scot" <bl***@blank.bl ank.com> wrote in message
news:c5******** @library1.airne ws.net...
I have the following code:

Dim IP, domainName As String
domainName = "yahoo.com"

Try
IP =

System.Net.Dns. GetHostByName(d omainName).Addr essList(0).ToSt ring()
Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLi ne(IP)
System.Threadin g.Thread.Sleep( 2000)
When it has a resolvable domain, like yahoo.com it responds back instantly with the ip address. However, if there is a domain in there that does not exist, like blue2343.com, it takes upwards of 5 seconds to print "Not

Valid"
to the screen. Why is that? and is there a way around it?

Thanks,

Scott


Nov 20 '05 #8
I think Charles is correct in his assumption. I understand that DNS lookups
on non-existant domains take longer, but not in the 3 to 5 second range. A
second or two would be acceptable, but even that would be long if you there
was minimal network latency.

I believe it is something in the Try..Catch segment. Anyone?
"Raymond Lewallen" <Ra************ ******@nospam.f aa.gov> wrote in message
news:Oq******** *****@tk2msftng p13.phx.gbl...
Scot,

This is mostly likely due to the time it is taking for your DNS server to
attempt to resolve the DNS name to an IP address. It is not uncommon for
3-6 seconds to pass while DNS attempts to resolve an entry that does not
exist. There is no way around the time it takes for a DNS server to exhaust its resources in an attempt to resolve hostnames to ip addresses.

HTH,

Raymond Lewallen

"Scot" <bl***@blank.bl ank.com> wrote in message
news:c5******** @library1.airne ws.net...
I have the following code:

Dim IP, domainName As String
domainName = "yahoo.com"

Try
IP =

System.Net.Dns. GetHostByName(d omainName).Addr essList(0).ToSt ring()
Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLi ne(IP)
System.Threadin g.Thread.Sleep( 2000)
When it has a resolvable domain, like yahoo.com it responds back instantly with the ip address. However, if there is a domain in there that does not exist, like blue2343.com, it takes upwards of 5 seconds to print "Not

Valid"
to the screen. Why is that? and is there a way around it?

Thanks,

Scott


Nov 20 '05 #9
Scot,

What happens when you step into the code? Does it takes this long everytime
you run the app, even if the process is not recycled? Charles is saying "I
have noticed that the first time an exception is thrown and caught, a .NET
application can take a significant time (several seconds) before returning
control to the catch block." Have you confirmed this is what is happening
by stepping into the try...catch block?

Raymond Lewallen

"Scot" <bl***@blank.bl ank.com> wrote in message
news:c5******** @library1.airne ws.net...
I think Charles is correct in his assumption. I understand that DNS lookups on non-existant domains take longer, but not in the 3 to 5 second range. A second or two would be acceptable, but even that would be long if you there was minimal network latency.

I believe it is something in the Try..Catch segment. Anyone?
"Raymond Lewallen" <Ra************ ******@nospam.f aa.gov> wrote in message
news:Oq******** *****@tk2msftng p13.phx.gbl...
Scot,

This is mostly likely due to the time it is taking for your DNS server to
attempt to resolve the DNS name to an IP address. It is not uncommon for 3-6 seconds to pass while DNS attempts to resolve an entry that does not
exist. There is no way around the time it takes for a DNS server to

exhaust
its resources in an attempt to resolve hostnames to ip addresses.

HTH,

Raymond Lewallen

"Scot" <bl***@blank.bl ank.com> wrote in message
news:c5******** @library1.airne ws.net...
I have the following code:

Dim IP, domainName As String
domainName = "yahoo.com"

Try
IP =

System.Net.Dns. GetHostByName(d omainName).Addr essList(0).ToSt ring()
Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLi ne(IP)
System.Threadin g.Thread.Sleep( 2000)
When it has a resolvable domain, like yahoo.com it responds back

instantly with the ip address. However, if there is a domain in there that does not exist, like blue2343.com, it takes upwards of 5 seconds to print "Not

Valid"
to the screen. Why is that? and is there a way around it?

Thanks,

Scott



Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6307
by: dmiller23462 | last post by:
Hey guys, I'm back again....I've got the results displaying that I wanted but instead of having a "next" or "previous" link displayed I am getting the error msg below (I actually get the data that I'm supposed to get meaning that my query seems to be working fine but instead of making its way to the INCLUDE file (bottom navigation bar) it displays the following error msg instead of the included nav bar... *** error '80020009' Exception...
18
4611
by: __frank__ | last post by:
The following code use a macro and a label. I would to change it and use instead a more readable function and avoid the label. The macro DAQmxFailed checks for the return code of the various functions: DAQmxCreateTask() DAQmxStartTask() DAQmxReadAnalogScalarF64()
7
3306
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte buffer into the character pointer. The code looks like the following: #include <stdio.h> #include <stdlib.h> #include "stdafx.h" BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call,
22
269
by: Scot | last post by:
I have the following code: Dim IP, domainName As String domainName = "yahoo.com" Try IP = System.Net.Dns.GetHostByName(domainName).AddressList(0).ToString() Catch ex As Exception IP = "Not Valid" End Try
2
1419
by: Bart Van der Donck | last post by:
Hello, I'm posting the software for one-FAQ-a-day as described on http://tinyurl.com/qcxw7 (comp.lang.javascript, July 18 2006, titled "CLJ newsgroup FAQ) and on http://tinyurl.com/ppt2s (comp.lang.javascript, July 22 2006, titled "Automation of comp.lang.javascript FAQ")
12
3204
by: Somebody | last post by:
Hi, I'm trying to write the function below and have it working, but I benchmarked it against strcmp() and its much slower. My test is to compare 2 strings that are identitical 100,000,000 times. Yeah, thats a lot, but I needed to scale up the test to get a real timing on the function. The weird thing is, even when I comment out almost the entire function, its still much slower then strcmp()... at full implementation, strcmp() takes 5...
28
1685
by: Platonic Solid | last post by:
Hi- I am learning C from some old lecture notes, but they don't have solutions so I'd like some feedback on my code if anyone has the time. This is an exercise: "Write a program to trim any leading whitespace from a string and return a newly allocated buffer containing the trimmed string. Don't forget to handle errors." main(argc, argv)
6
2444
by: dragiton | last post by:
ASP Code Redirect Error Hello I recently relaunched a website containing asp code which used to work perfectly. However, after resetting up the SQL DB and trying to work out some site bugs I have the following problem: any suggestions? I have a newuser login page that creates a new SQL DB table record with login name and password then takes the user to the next (page) step in the registration setup. Currently the record is created in the...
10
2472
by: =?Utf-8?B?R3JlZw==?= | last post by:
I have the following three files. 1. Users.aspx is a webpage that uses the <asp:ObjectDataSourcecontrol to populate a simple <asp:ListBoxcontrol. 2. The UserDetails.cs file creates a Namespace named UserComponents and creates an object named UserDetails. 3. The UserDB.cs file retrieves the actual data from the database. The code below has been condensed and only includes two fields from my datasource. I actually am also retrieving...
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.