We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Timeout of loadimage()
Page Index Toggle Pages: 1
Timeout of loadimage() (Read 662 times)
Timeout of loadimage()
Jul 22nd, 2005, 2:04am
 
What is the best way of adding a timeout function to loadimage()? I'm loading images from unknown hosts and some might be to slow and has to be canceled after a minute or so if not finished.
Re: Timeout of loadimage()
Reply #1 - Jul 22nd, 2005, 10:52pm
 
Ok I solved it for now with a parameter passed to java since I can have it running like that for now. I think that I will try the threading stuff mentioned later on (I dont have the time at the moment)

From what I can see one way is to load the image in a thread allowing me to stop it when I want.
Another way (if run from command line and java >1.4.something) is to use the  -Dsun.net.client.defaultReadTimeout switch and catch the exception.

sun.net.client.defaultConnectTimeout (default: -1)
sun.net.client.defaultReadTimeout (default: -1)
http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html

Here are some other resources that seems useful.
http://forum.java.sun.com/thread.jspa?messageID=3730209
http://coding.derkeiler.com/Archive/Java/comp.lang.java.programmer/2004-01/3271.html


Re: Timeout of loadimage()
Reply #2 - Jan 20th, 2007, 3:23am
 
sorry to dig this back up from the grave...

I'm running into the same problem however containing it in a thread doesn't help. Timeout exceptions doesn't get caught by try/catch when you do loadImage() and it generally crashes everything or makes further netloading impossible.

I don't quite get the examples you've posted following the thread idea. Can you please elaborate, if you've tried those? They look like re-writes for the network library, I'm not sure exactly how we could implement those into our processing apps.

Thanks!
Page Index Toggle Pages: 1