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

[1037 byte] By [murtana] at [2007-11-26 12:46:45]
# 1
You can't detect a TCP ACK, it is hidden from the application by the transport. If you want an ACK at the application level you have to send it yourself.
ejpa at 2007-7-7 16:27:26 > top of Java-index,Archived Forums,Socket Programming...