Thanks for all the replies!

>From another thread I've tried:

mInputStream.close();
mRequest.abort();
mClientConnectionManager.shutdown();
mDownloadThread.interrupt();

All allow the read operation to complete.

Maybe I shouldn't be using a SingleClientConnManager ... ?

On Jan 7, 10:25 am, DanH <danhi...@ieee.org> wrote:
> In the general (platform agnostic) case you solve this by having the
> stream "relay" though a service of some sort (eg, a thread) that is
> listening for messages from both the HTTP stream handler and whatever
> entity you have that will send the interrupt message.  How you'd do
> this best on Android I haven't a clue.
>
> On Jan 7, 11:07 am, ivan <istas...@gmail.com> wrote:
>
> > I'm wondering what the currently suggested method is for interrupting
> > a read operation of a socket input stream?
>
> > I know that traditionally the read could be interrupted by closing the
> > socket from another thread and catching an IOException, but I'm not
> > quite sure how to get at the socket from the apache classes.
>
> > Maybe I should use some sort of interruptible channel instead ... ?
>
> > Any links or help is greatly appreciated.
>
> > My code looks like this -- minus most of the error handling:
>
> > org.apache.http.impl.client.DefaultHttpClient
> > org.apache.http.client.methods.HttpGet
> > org.apache.http.HttpResponse
>
> > DefaultHttpClient client = new DefaultHttpClient(httpParameters);
>
> > HttpGet request = new HttpGet(Uri);
>
> > HttpResponse response = client.execute(request);
>
> > InputStream entityStream = response.getEntity().getContent();
>
> > try
> > {
> >    bytesRead = entityStream.read(data);}
>
> > catch (IOException ex)
> > {
>
> > }

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to