Issue
I am using Volley as my networking library for my Android project. I'm curious to know when is a network connection opened and if Volley maintains the same connection when executing multiple POST requests using same request URL?
Solution
The answer lies in the HttpStackinterface implementation. Volley has two out of the box - the HurlStack that uses HttpUrlConnection and HttpClientStack that uses the Apache library.
A quick look at HurlStack shows that a new HttpUrlConnection object is created per request. Normally, connection pooling and reuse is handled by the HttpUrlConnection itself. I think that it will behave as smartly as possible and reuse as much resources as possible.
The same applies for the HttpClientStack. It uses a shared HttpClient to perform requests, so it's up to Apache's library to deal with connection pooling, etc.
To summarise, low-level network creation and maintenance is not something with which Volley deals directly. It's all a question of specific implementations, but, as far as I can remember, they will do as much of the heavy lifting for you as possible.
Answered By - Danail Alexiev
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.