I know and understand that android does not allow synchronous sockets, so we have to use async. My problem is that i dont know how to optimize my code acording to me needs.
To summary, i have:
a socket, a connected event, the input/output streams and the receivedata event.
Imagine i have to code an app that needs to send a lot of text like:
-order 1
-get response
-order 2
-get response
...
what is the best way to handle the responses from the server? im testing in a local network so no network congestion packet loss etc, but what if in production order 2 arrives first? how can i know that the data received is "from" order 1 without modifying the code at the server (for example, including a number in every response that would match the order number)? tcp/ip stack in android would do it for me?
To summary, i have:
a socket, a connected event, the input/output streams and the receivedata event.
Imagine i have to code an app that needs to send a lot of text like:
-order 1
-get response
-order 2
-get response
...
what is the best way to handle the responses from the server? im testing in a local network so no network congestion packet loss etc, but what if in production order 2 arrives first? how can i know that the data received is "from" order 1 without modifying the code at the server (for example, including a number in every response that would match the order number)? tcp/ip stack in android would do it for me?