How can I explicitly wait for the TCP ACK before continuing?

Is there a way to get send () to wait until all the data that was sent was ACK-ed (or return -1 if the timeout for the ACK was reached), or is there some other mechanism to wait for the ACK after send (), but before doing anything else?

I am using the standard Unix Berkeley socket API.

I know that I can implement the ACK at the application level, but I would prefer not to do this when the TCP ACK performs this task perfectly.

+6
source share
4 answers

Unfortunately, the standard API does not reserve a suitable way to do this. There may be a way to request the current size / use of the TCP send window, but, unfortunately, it cannot be requested by standard means.

Of course, there are complex ways to achieve what you want. For example, on Windows, you can create a surge protector to monitor packet-level traffic.

+4
source

AFAIK there is no way.

In addition, it would not be reliable, ACK only means that the kernel received data, while the client or its machine could be broken. You might think that the client received the data, but actually he never processed it.

+5
source

I seem to have found a solution. At least on Linux, if you set SO_SNDBUF to 0, it seems to wait for every transaction before allowing the next transfer. While he will immediately return, he will not proceed to permit another dispatch until he dispatches the previous dispatch. I have not tried using select (...) to determine if data was sent.

This works on my Linux 3.8 kernel, and I'm sure it works elsewhere.

+2
source

You can write a shell for send (). I answered a question similar to this question in a different thread .

0
source

Source: https://habr.com/ru/post/902058/


All Articles