sockets: How to know when your data is sent

Sion Arrowsmith siona at
Tue Nov 9 17:34:04 CET 2004

Grant Edwards  <grante at> wrote:
>On 2004-11-09, Marc Ederis <mederis at> wrote:
>>  When I use the send function, it will
>> happily send a buffer of a megabyte and more in one shot. But
>> of course, the data is still in the network buffer... 
>>  [ ... ] The
>> problem is, how can I know when it's done?
>Under Linux, there is no way to tell.  IIRC, there's no way to
>tell under BSD either.  I actually wrote some kernel mode code
>once upon a time to provide an ioctl() that I could call from
>user space to find out when the data I had written to a socket
>was actually sent.

I may well be missing the point of the problem here, but wouldn't
just turning TCP_NODELAY on guarantee that send() won't return
until the last ACK has returned? And if you're not using TCP:

>The way to tell that data has been sent is to use an
>application-level protocol that acknowleges the data transferr.

applies in spades if you care about reliability.

\S -- siona at --
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |    -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump

More information about the Python-list mailing list