[Twisted-Python] A question about ITransport.write()
andrew-twisted at puzzling.org
Sun Dec 28 02:13:17 EST 2008
Lian Cheng wrote:
> Hi, all
> As a Twisted newbie, I read the Twisted documentation, and found that:
> 1. ITransport.write() doesn't return a deferred.
> 2. IProtocol doesn't have a dataSent() callback or something alike.
> Since ITransport.write() is a non-blocking call, how can I be informed
> when data sent by ITransport.write() is actually sent successfully?
It depends on what exactly you mean by "successfully". Just because Twisted
has delivered the bytes to the OS for delivery (e.g. via the send(2)
syscall) doesn't mean they'll actually arrive at your intended destination.
If you want to know if the bytes have arrived, get the remote side to send
back an explicit ACK of some sort.
If you want to know when the send buffer isn't full anymore, so that you
can start working to fill it again, implement a pull producer
and call the transport's registerProducer method with it.
If you want something else, reply and tell us what :)
 “send buffer” is fairly loose terminology, but it'll do.
More information about the Twisted-Python