Thursday, April 4, 2013

[android-developers] Can't interrupt/abort InetAddress.getByName()

I have a thread that is doing Datagram(UDP) Socket communication.
But I want to be able to interrupt/abort this thread at any time from
my main UI. For blocking socket calls like read() and send() I can do
this very well by calling interrupt() on the thread object. After
those blocking calls my thread checks a flag to see if the main UI is
telling it to quit. If so, then it quits. But for
InetAddress.getByName() this doesn't seem to work. This call can
block for a long time (up to 20 seconds in one test I did) if the
Internet is not accessible for some reason. That is a long time to
wait to abort a thread. What is the right way to cause a thread to
abort a call to InetAddress.getByName() ?

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate