title: Android and SO_KEEPALIVE - will a sleeping device still send keepalive segments?
body: <p>When the screen is off, Android devices usually turn off the CPU and go to a deep hibernation state unless some application is holding a wakelock. The system <a href="https://stackoverflow.com/questions/5007721/android-sleep-stages-levels-on-an-android-device">only wakes up</a> from that state upon device interrupts (e.g. incoming data from the network) or when a scheduled alarm fires. This seems to be very different from a CPU sleep state, where periodic timer interrupts regularly wake up the CPU.</p>
  
  <p>Does this mean that all network events/timers are also suspended (e.g. TCP retransmissions and keepalives), or are they registered as alarms by the Kernel?</p>
  
  <p>I'm wondering if this could interfere with the operation of socket-level keepalives (via the SO_KEEPALIVE socket option). Will this option still work on an Android device, or does this have to be handled by the application on a higher layer?</p>