title: Android socket stable communication
body: <p>I am  working on Android project which communicates over TCP/IP. Communication works on specific protocol - this protocol is message oriented.</p>
  
  <ol>
  <li>android device sends message to server via socket</li>
  <li>server sends answer message to android device</li>
  </ol>
  
  <p>It is not problem but I have a few parlous questions.</p>
  
  <p>I don't have any idea how to solve connection interrupts (wifi, edge, change wifi to edge over open socket, ...) and connection timeouts? If android device sends 1 message and in this moment are connection problems - then android device sends different message (other request) - it is guaranteed that answers will be delivered in correct sequence?</p>
  
  <p>I tried set timeout for socket object but it didn't work. I dont know why but if I set timeout to 5 seconds and I turned off the server before I sent message - it took more than 5 second before she came exciption.</p>
  
  <p>I didn't found any articles on internet about this problems.</p>
  
  <p>Thank you very much.</p>