Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

URL probrlm

Thread view: 
jack.smith.sam@gmail.com - 22 Oct 2006 22:18 GMT
Hi a All,

I use these line to get a url.
url = new URL(Url);
BufferedReader in = new BufferedReader(new
InputStreamReader(url.openStream()));

but in some cases I got connection timed out error and program exit. As
I want to get lots of URLs this will cause problem. Is there any way
that I detect connectino timed out and in that case what is the best
thing to do? resending URL?

Thanks a lot.
nikk_and_jak@btinternet.com - 23 Oct 2006 02:44 GMT
Hi,
I guess it depends on how you program flows, but when I have needed to
connect to multiple URL's, I have put each attempt in a separate
thread.  That way, you will be able to continue processing whilst
waiting for a url to come in.

If you want to control the connection timeout period for a URL, i.e.
set it, URL has a method setConnectTimeout(int millis).  See:

http://java.sun.com/j2se/1.5.0/docs/api/java/net/URLConnection.html#setConnectTi
meout(int
)

You have to be careful about firing off too many url requests at once,
as you can really jam up your bandwidth, so the number of concurrent
threads you run will be found through trial and error.

Hope that helps

Nikk


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.