I have a client socket which sends messages to the server.I want to get an acknowledgement on the client side whenever the server receives the message. Is it possible to get that acknowledgement. I developed the client using apache mina. Thanks in advance.
Asked
Active
Viewed 3,216 times
1 Answers
2
There are no messages in TCP, only a byte stream. There is an internal ACK mechanism that tracks how much of the stream has been correctly received, but it is not available to applications. If you want an acknowledgment from the server, your server will have to send it.

user207421
- 305,947
- 44
- 307
- 483
-
Thanks for your answer EJP. I cannot write on the server side because it is a gateway. Is there any method in java which shows that internal ACK mechanism or can we write any programming on the transport layer to get that ack. – Rocky Oct 09 '12 at 06:50
-
@Rocky It is not available to applications, as I already said. – user207421 Oct 09 '12 at 08:31
-
Note that even knowing if a remote machine ACK'd the data would not tell you "when" or even "if" the server application had received it. Still, I've always thought it was a shame that there was no `ioctl()` to get that information. – Brian White Oct 09 '12 at 14:29
-
@BrianWhite Isn't there an ioctl() that tells you how much room there is in the send buffer? That indirectly tells you where the ACK mechanism is up to, but you would really need a callback mechanism or a select() event on ACK, or else a mechanism to make send() block until the ACK came in, but then you would lose TCP windowing of course. – user207421 Oct 09 '12 at 17:33
-
This other question might have some relevant information: http://stackoverflow.com/questions/1803215/how-can-i-tell-if-a-socket-buffer-is-full – Brian White Oct 09 '12 at 17:47