Hi at all,
I am writing a little application that make a heavy use of image from
internet, but I have a little issue.

I have write this code for download images over internet, these image
fill some  fields on a ListView :

                        loop{

                                method = new HttpGet(myURL);
                                response = client_http.execute(method);
                                entity = response.getEntity();
                                BufferedHttpEntity bufHttpEntity = new
BufferedHttpEntity(entity);
                                in = bufHttpEntity.getContent();
                                image = BitmapFactory.decodeStream(in);
                                in.close();
                                actual.setImage(image);
                                // non utilizzabile image.recycle();
                                actual.setImageReady();
                                publishProgress(i);

                        }

All images are download correctly but if I see the packet with
WireShark all HTTP request have a different source port, this means
that for EACH request one socket is open.I download all image from the
same domain, the only different is the URL inside the domain itself.

This is my DefaultHTTPClient configuration:

HttpParams parameters = new BasicHttpParams();
HttpProtocolParams.setVersion(parameters, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(parameters, HTTP.UTF_8);
HttpProtocolParams.setUseExpectContinue(parameters, false); // some
webservers have problems if this is set to true
ConnManagerParams.setMaxTotalConnections(parameters,
ConnManagerParams.DEFAULT_MAX_TOTAL_CONNECTIONS);
HttpConnectionParams.setConnectionTimeout(parameters, 5000);
HttpConnectionParams.setSoTimeout(parameters, 5000);
SchemeRegistry schReg = new SchemeRegistry();
schReg.register(new Scheme("http",
PlainSocketFactory.getSocketFactory(), 80));
ClientConnectionManager conMgr = new
ThreadSafeClientConnManager(parameters,schReg);
DefaultHttpClient http_client = new DefaultHttpClient(conMgr,
parameters);

Anyone knows the way to use only one socket for all the HTTP request
without write by hands?

Thanks a lot.




-- 
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