473,326 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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(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
22 1524
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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

"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

"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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
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...
18
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...
7
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...
22
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...
2
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...
12
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....
28
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...
6
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...
10
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.