By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,873 Members | 1,040 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,873 IT Pros & Developers. It's quick & easy.

code takes a while to return if error

P: n/a
I have the following code:

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

Try
IP = System.Net.Dns.GetHostByName(domainName).AddressLi st(0).ToString()
Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLine(IP)
System.Threading.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
Share this Question
Share on Google+
22 Replies


P: n/a
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.blank.com> wrote in message
news:c5********@library1.airnews.net...
I have the following code:

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

Try
IP = System.Net.Dns.GetHostByName(domainName).AddressLi st(0).ToString() Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLine(IP)
System.Threading.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

P: n/a
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.blank.com> wrote in message
news:c5********@library1.airnews.net...
I have the following code:

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

Try
IP = System.Net.Dns.GetHostByName(domainName).AddressLi st(0).ToString() Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLine(IP)
System.Threading.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

P: n/a
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.faa.gov> wrote in message
news:Oq*************@tk2msftngp13.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.blank.com> wrote in message
news:c5********@library1.airnews.net...
I have the following code:

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

Try
IP =

System.Net.Dns.GetHostByName(domainName).AddressLi st(0).ToString()
Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLine(IP)
System.Threading.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

P: n/a
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.faa.gov> wrote in message
news:Oq*************@tk2msftngp13.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.blank.com> wrote in message
news:c5********@library1.airnews.net...
I have the following code:

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

Try
IP =

System.Net.Dns.GetHostByName(domainName).AddressLi st(0).ToString()
Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLine(IP)
System.Threading.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

P: n/a
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**************@tk2msftngp13.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.faa.gov> wrote in message
news:Oq*************@tk2msftngp13.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.blank.com> wrote in message
news:c5********@library1.airnews.net...
I have the following code:

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

Try
IP =

System.Net.Dns.GetHostByName(domainName).AddressLi st(0).ToString()
Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLine(IP)
System.Threading.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

P: n/a
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**************@tk2msftngp13.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.faa.gov> wrote in message
news:Oq*************@tk2msftngp13.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.blank.com> wrote in message
news:c5********@library1.airnews.net...
I have the following code:

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

Try
IP =

System.Net.Dns.GetHostByName(domainName).AddressLi st(0).ToString()
Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLine(IP)
System.Threading.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

P: n/a
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.faa.gov> wrote in message
news:Oq*************@tk2msftngp13.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.blank.com> wrote in message
news:c5********@library1.airnews.net...
I have the following code:

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

Try
IP =

System.Net.Dns.GetHostByName(domainName).AddressLi st(0).ToString()
Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLine(IP)
System.Threading.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

P: n/a
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.faa.gov> wrote in message
news:Oq*************@tk2msftngp13.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.blank.com> wrote in message
news:c5********@library1.airnews.net...
I have the following code:

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

Try
IP =

System.Net.Dns.GetHostByName(domainName).AddressLi st(0).ToString()
Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLine(IP)
System.Threading.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

P: n/a
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.blank.com> wrote in message
news:c5********@library1.airnews.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.faa.gov> wrote in message
news:Oq*************@tk2msftngp13.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.blank.com> wrote in message
news:c5********@library1.airnews.net...
I have the following code:

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

Try
IP =

System.Net.Dns.GetHostByName(domainName).AddressLi st(0).ToString()
Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLine(IP)
System.Threading.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

P: n/a
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.blank.com> wrote in message
news:c5********@library1.airnews.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.faa.gov> wrote in message
news:Oq*************@tk2msftngp13.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.blank.com> wrote in message
news:c5********@library1.airnews.net...
I have the following code:

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

Try
IP =

System.Net.Dns.GetHostByName(domainName).AddressLi st(0).ToString()
Catch ex As Exception
IP = "Not Valid"
End Try

Console.WriteLine(IP)
System.Threading.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 #11

P: n/a
I haven't tried that. Unfortunately I am not an "official" programmer, so I
more or less hack things together until they work. I wouldn't have even the
first bit of a clue as far as how to step into the try....catch block. In
fact this is the first time I have ever used one in vb.net, and it was only
because I couldn't solve the situation another way.

It takes this long everytime I run the app, but it is started from scratch
each time.
"Raymond Lewallen" <Ra******************@nospam.faa.gov> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
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.blank.com> wrote in message
news:c5********@library1.airnews.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.faa.gov> wrote in message
news:Oq*************@tk2msftngp13.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.blank.com> wrote in message
news:c5********@library1.airnews.net...
> I have the following code:
>
> Dim IP, domainName As String
> domainName = "yahoo.com"
>
> Try
> IP =
System.Net.Dns.GetHostByName(domainName).AddressLi st(0).ToString()
> Catch ex As Exception
> IP = "Not Valid"
> End Try
>
> Console.WriteLine(IP)
> System.Threading.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 #12

P: n/a
I haven't tried that. Unfortunately I am not an "official" programmer, so I
more or less hack things together until they work. I wouldn't have even the
first bit of a clue as far as how to step into the try....catch block. In
fact this is the first time I have ever used one in vb.net, and it was only
because I couldn't solve the situation another way.

It takes this long everytime I run the app, but it is started from scratch
each time.
"Raymond Lewallen" <Ra******************@nospam.faa.gov> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
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.blank.com> wrote in message
news:c5********@library1.airnews.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.faa.gov> wrote in message
news:Oq*************@tk2msftngp13.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.blank.com> wrote in message
news:c5********@library1.airnews.net...
> I have the following code:
>
> Dim IP, domainName As String
> domainName = "yahoo.com"
>
> Try
> IP =
System.Net.Dns.GetHostByName(domainName).AddressLi st(0).ToString()
> Catch ex As Exception
> IP = "Not Valid"
> End Try
>
> Console.WriteLine(IP)
> System.Threading.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 #13

P: n/a
Scot, set a breakpoint on your GetHostByName line (right-click on the line
and click set breakpoint). When you run the app it will stop there, and
then hit F11 to step into the code line by line and you will see where the
hic-cup is occurring.
Nov 20 '05 #14

P: n/a
Scot, set a breakpoint on your GetHostByName line (right-click on the line
and click set breakpoint). When you run the app it will stop there, and
then hit F11 to step into the code line by line and you will see where the
hic-cup is occurring.
Nov 20 '05 #15

P: n/a
I set the breakpoint on that line, then hit F11.

It highlights Sub Main() in yellow with a yellow arrow to the left.
F11 again, domainName line is now in yellow
F11, Try in yello
F11, breakpoint line in yellow
F11, End Try in yellow
F11, console.writeline in yellow
F11, sleep in yellow
then End Sub ends up in yellow

Nothing seems to take the 5 seconds, even when I rapidly go through it with
F11.

"Raymond Lewallen" <Ra******************@nospam.faa.gov> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
Scot, set a breakpoint on your GetHostByName line (right-click on the line
and click set breakpoint). When you run the app it will stop there, and
then hit F11 to step into the code line by line and you will see where the
hic-cup is occurring.

Nov 20 '05 #16

P: n/a
I set the breakpoint on that line, then hit F11.

It highlights Sub Main() in yellow with a yellow arrow to the left.
F11 again, domainName line is now in yellow
F11, Try in yello
F11, breakpoint line in yellow
F11, End Try in yellow
F11, console.writeline in yellow
F11, sleep in yellow
then End Sub ends up in yellow

Nothing seems to take the 5 seconds, even when I rapidly go through it with
F11.

"Raymond Lewallen" <Ra******************@nospam.faa.gov> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
Scot, set a breakpoint on your GetHostByName line (right-click on the line
and click set breakpoint). When you run the app it will stop there, and
then hit F11 to step into the code line by line and you will see where the
hic-cup is occurring.

Nov 20 '05 #17

P: n/a

"Scot" <bl***@blank.blank.com> wrote in message
news:c5********@library1.airnews.net...
I haven't tried that. Unfortunately I am not an "official" programmer,
Ha! don't worry about being an official programmer. I've met "official" or
"professional" programmers that don't know a damn thing. =)
so I
more or less hack things together until they work. I wouldn't have even the first bit of a clue as far as how to step into the try....catch block. In
fact this is the first time I have ever used one in vb.net, and it was only because I couldn't solve the situation another way.

It takes this long everytime I run the app, but it is started from scratch
each time.
"Raymond Lewallen" <Ra******************@nospam.faa.gov> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
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.blank.com> wrote in message
news:c5********@library1.airnews.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.faa.gov> wrote in message news:Oq*************@tk2msftngp13.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.blank.com> wrote in message
> news:c5********@library1.airnews.net...
> > I have the following code:
> >
> > Dim IP, domainName As String
> > domainName = "yahoo.com"
> >
> > Try
> > IP =
> System.Net.Dns.GetHostByName(domainName).AddressLi st(0).ToString()
> > Catch ex As Exception
> > IP = "Not Valid"
> > End Try
> >
> > Console.WriteLine(IP)
> > System.Threading.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 #18

P: n/a

"Scot" <bl***@blank.blank.com> wrote in message
news:c5********@library1.airnews.net...
I haven't tried that. Unfortunately I am not an "official" programmer,
Ha! don't worry about being an official programmer. I've met "official" or
"professional" programmers that don't know a damn thing. =)
so I
more or less hack things together until they work. I wouldn't have even the first bit of a clue as far as how to step into the try....catch block. In
fact this is the first time I have ever used one in vb.net, and it was only because I couldn't solve the situation another way.

It takes this long everytime I run the app, but it is started from scratch
each time.
"Raymond Lewallen" <Ra******************@nospam.faa.gov> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
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.blank.com> wrote in message
news:c5********@library1.airnews.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.faa.gov> wrote in message news:Oq*************@tk2msftngp13.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.blank.com> wrote in message
> news:c5********@library1.airnews.net...
> > I have the following code:
> >
> > Dim IP, domainName As String
> > domainName = "yahoo.com"
> >
> > Try
> > IP =
> System.Net.Dns.GetHostByName(domainName).AddressLi st(0).ToString()
> > Catch ex As Exception
> > IP = "Not Valid"
> > End Try
> >
> > Console.WriteLine(IP)
> > System.Threading.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 #19

P: n/a
Scot,

Not the first time I've seen something like this. I've actually had code
that would throw exceptions when just running through it, but when I stepped
through it, would work just fine! It stinks to say it, but rebooting often
helped that problem (not that it actually occurred on a regular basis). I'm
afraid I have no more advice on the subject, and I hate to leave you with
"Maybe you'll have to live with it", so hopefully someone else will have a
good suggestion.

Sorry I couldn't be of more help,

Raymond Lewallen
"Scot" <bl***@blank.blank.com> wrote in message
news:c5********@library1.airnews.net...
I set the breakpoint on that line, then hit F11.

It highlights Sub Main() in yellow with a yellow arrow to the left.
F11 again, domainName line is now in yellow
F11, Try in yello
F11, breakpoint line in yellow
F11, End Try in yellow
F11, console.writeline in yellow
F11, sleep in yellow
then End Sub ends up in yellow

Nothing seems to take the 5 seconds, even when I rapidly go through it with F11.

"Raymond Lewallen" <Ra******************@nospam.faa.gov> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
Scot, set a breakpoint on your GetHostByName line (right-click on the line and click set breakpoint). When you run the app it will stop there, and
then hit F11 to step into the code line by line and you will see where the hic-cup is occurring.


Nov 20 '05 #20

P: n/a
Scot,

Not the first time I've seen something like this. I've actually had code
that would throw exceptions when just running through it, but when I stepped
through it, would work just fine! It stinks to say it, but rebooting often
helped that problem (not that it actually occurred on a regular basis). I'm
afraid I have no more advice on the subject, and I hate to leave you with
"Maybe you'll have to live with it", so hopefully someone else will have a
good suggestion.

Sorry I couldn't be of more help,

Raymond Lewallen
"Scot" <bl***@blank.blank.com> wrote in message
news:c5********@library1.airnews.net...
I set the breakpoint on that line, then hit F11.

It highlights Sub Main() in yellow with a yellow arrow to the left.
F11 again, domainName line is now in yellow
F11, Try in yello
F11, breakpoint line in yellow
F11, End Try in yellow
F11, console.writeline in yellow
F11, sleep in yellow
then End Sub ends up in yellow

Nothing seems to take the 5 seconds, even when I rapidly go through it with F11.

"Raymond Lewallen" <Ra******************@nospam.faa.gov> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
Scot, set a breakpoint on your GetHostByName line (right-click on the line and click set breakpoint). When you run the app it will stop there, and
then hit F11 to step into the code line by line and you will see where the hic-cup is occurring.


Nov 20 '05 #21

P: n/a
No problem, Raymond. I'll figure something out. Thanks for trying.

Scott
"Raymond Lewallen" <Ra******************@nospam.faa.gov> wrote in message
news:O5**************@TK2MSFTNGP10.phx.gbl...
Scot,

Not the first time I've seen something like this. I've actually had code
that would throw exceptions when just running through it, but when I stepped through it, would work just fine! It stinks to say it, but rebooting often helped that problem (not that it actually occurred on a regular basis). I'm afraid I have no more advice on the subject, and I hate to leave you with
"Maybe you'll have to live with it", so hopefully someone else will have a
good suggestion.

Sorry I couldn't be of more help,

Raymond Lewallen
"Scot" <bl***@blank.blank.com> wrote in message
news:c5********@library1.airnews.net...
I set the breakpoint on that line, then hit F11.

It highlights Sub Main() in yellow with a yellow arrow to the left.
F11 again, domainName line is now in yellow
F11, Try in yello
F11, breakpoint line in yellow
F11, End Try in yellow
F11, console.writeline in yellow
F11, sleep in yellow
then End Sub ends up in yellow

Nothing seems to take the 5 seconds, even when I rapidly go through it

with
F11.

"Raymond Lewallen" <Ra******************@nospam.faa.gov> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
Scot, set a breakpoint on your GetHostByName line (right-click on the

line and click set breakpoint). When you run the app it will stop there, and then hit F11 to step into the code line by line and you will see where the hic-cup is occurring.



Nov 20 '05 #22

P: n/a
No problem, Raymond. I'll figure something out. Thanks for trying.

Scott
"Raymond Lewallen" <Ra******************@nospam.faa.gov> wrote in message
news:O5**************@TK2MSFTNGP10.phx.gbl...
Scot,

Not the first time I've seen something like this. I've actually had code
that would throw exceptions when just running through it, but when I stepped through it, would work just fine! It stinks to say it, but rebooting often helped that problem (not that it actually occurred on a regular basis). I'm afraid I have no more advice on the subject, and I hate to leave you with
"Maybe you'll have to live with it", so hopefully someone else will have a
good suggestion.

Sorry I couldn't be of more help,

Raymond Lewallen
"Scot" <bl***@blank.blank.com> wrote in message
news:c5********@library1.airnews.net...
I set the breakpoint on that line, then hit F11.

It highlights Sub Main() in yellow with a yellow arrow to the left.
F11 again, domainName line is now in yellow
F11, Try in yello
F11, breakpoint line in yellow
F11, End Try in yellow
F11, console.writeline in yellow
F11, sleep in yellow
then End Sub ends up in yellow

Nothing seems to take the 5 seconds, even when I rapidly go through it

with
F11.

"Raymond Lewallen" <Ra******************@nospam.faa.gov> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
Scot, set a breakpoint on your GetHostByName line (right-click on the

line and click set breakpoint). When you run the app it will stop there, and then hit F11 to step into the code line by line and you will see where the hic-cup is occurring.



Nov 20 '05 #23

This discussion thread is closed

Replies have been disabled for this discussion.