473,794 Members | 2,754 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
22 1562
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.bl ank.com> wrote in message
news:c5******** @library1.airne ws.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.writeli ne 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.f aa.gov> wrote in message
news:ur******** ******@TK2MSFTN GP10.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.f aa.gov> wrote in message
news:O5******** ******@TK2MSFTN GP10.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.bl ank.com> wrote in message
news:c5******** @library1.airne ws.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.writeli ne 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.f aa.gov> wrote in message
news:ur******** ******@TK2MSFTN GP10.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.f aa.gov> wrote in message
news:O5******** ******@TK2MSFTN GP10.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.bl ank.com> wrote in message
news:c5******** @library1.airne ws.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.writeli ne 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.f aa.gov> wrote in message
news:ur******** ******@TK2MSFTN GP10.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
6314
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
3308
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
1422
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
1688
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
9671
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
9518
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,...
1
10161
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
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9035
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...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4112
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2919
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.