Detection of TCP ACK
Hi!
I'm writing a server - client (computer - mobile phone) application which need to be able to comunicate directly with each other. I need to send some kind of heartbeat to the client every few minutes to make sure it's still online. Also, it is crucial that traffic (in bytes) is minimized.
My idea: Establish a (TCP) stream socket connection on startup. Every few minutes, send a one-byte-content packet from the server to the client, for example by
OutputStream.write(int);
OutputStream.flush();
Since the TCP protocol makes sure that the client responds with an ACK packet once it has received the packet, this should be able to detect in the server application.
The problem: how do I detect an TCP ACK packet in Java?
An alternative is to make the client respond with a one-byte-content packet itself, but this doubles the traffic amount. I have many clients connected at once (in differend threads) and would prefer TCP over UDP.
Any suggestions?
Regards,
Erik

