I'm developing an application which needs a persistent TCP connection to server. I'm trying to understand what is the proper way of dealing with persistent connections to avoid draining the battery quickly. My understanding is if a socket is connected to the server and the CPU goes to sleep, if packets are received on that connection the CPU will wake up. The thing I don't know is when it will go back to sleep again. Do I need to grab a WakeLock right after the read operation and release it after I'm done processing the incoming packet? If I don't grab the WakeLock is there the concept of an execution context which ends when the current thread goes to the blocking or sleeping state?
One think I noticed when using the HttpConnection is that getResponseCode (which is a blocking call) will NOT wake up if the CPU goes to sleep. At this time I am considering writing my own HTTP connection class in order to gain fine control over the behavior of the class in regards to the CPU sleep issue. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---