How to support HTTP persistent connection on android -


im current developing android application opens new connection every single request/response pair using http 1.1 , async task, need change supporting persistent connection using get method, whenever server sends information can catch listener.

im stuck this, there reference http persistent connection on android?

i answer question didn't ask - persistent connections idea? generally, no - not @ all. there several reasons. , i'm sure don't mean http (as designed stateless), want tcp/ip port opened.

first, battery drain. tcp connections resource intensive - creation/tear down of http connection better open socket.

second, http doesn't require this. use-case may different, maybe shouldn't using http. maybe xmpp or "long polling" type solution?

third, should warned carriers change ip addresses on frequent basis. while next response may encourage you, real-world testing , use may not meet expectations...

last, can modify "timeout" of request, , thereby keep connection "open" until server responds. "long polling" - in sense. tell server expecting response might take while (like timeout of 5 or 10 minutes), in mean time, carrier changes ip address or user moves tower... happens.

if these don't apply you, please more specific use-case or scenario.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -