[Twisted-Python] How to determine whether transport.write() succeed?
Hi, everyone How could I dertermine ITransport.write() succeed? In windows socket API, I can check send()'s return value to dertermine whether send() succeed. Any suggestion is appreciated.
On Mar 31, 2013, at 1:50 AM, Todong Ma <gbstack08@gmail.com> wrote:
Hi, everyone
How could I dertermine ITransport.write() succeed? In windows socket API, I can check send()'s return value to dertermine whether send() succeed.
Any suggestion is appreciated.
ITransport.write() always succeeds. It may or may not call socket.send immediately, so it cannot tell you if the socket.send() succeeded or not. What are you trying to do? -glyph
I wrote a simple client and server to get system information (e.g. cpu, memory, etc.) Client send 'cpu' to the server, then server will return cpu's information to client. Now client send multiple commands to server one time, e.g. cpu, memory, database, hard disk. But sometimes server couldn't receive some type information (e.g. cpu, database), and the missed information type is not fixed every time. So I want client to check whether ITransport.write() sends message to server successfully. If failed, client will resend the message to server. On Sun, Mar 31, 2013 at 5:49 PM, Glyph <glyph@twistedmatrix.com> wrote:
On Mar 31, 2013, at 1:50 AM, Todong Ma <gbstack08@gmail.com> wrote:
Hi, everyone
How could I dertermine ITransport.write() succeed? In windows socket API, I can check send()'s return value to dertermine whether send() succeed.
Any suggestion is appreciated.
ITransport.write() always succeeds. It may or may not call socket.send immediately, so it cannot tell you if the socket.send() succeeded or not.
What are you trying to do?
-glyph
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
On Mar 31, 2013, at 6:09 PM, Todong Ma <gbstack08@gmail.com> wrote:
I wrote a simple client and server to get system information (e.g. cpu, memory, etc.) Client send 'cpu' to the server, then server will return cpu's information to client.
Now client send multiple commands to server one time, e.g. cpu, memory, database, hard disk. But sometimes server couldn't receive some type information (e.g. cpu, database), and the missed information type is not fixed every time.
So I want client to check whether ITransport.write() sends message to server successfully. If failed, client will resend the message to server.
It's a good thing that write() doesn't convey information about send() succeeding so you can't trust it :). You can't rely on send() succeeding to convey this information: send() can succeed but all that means is that data moved from your application into your kernel. What you want to do is to have an application-level acknowledgement of the data that was sent. AMP will provide this for you automatically; when the Deferred returned by callRemote fires, the other end has received and acknowledged the information. -glyph
Ok, will try AMP thank you very much! On Mon, Apr 1, 2013 at 3:49 PM, Glyph <glyph@twistedmatrix.com> wrote:
On Mar 31, 2013, at 6:09 PM, Todong Ma <gbstack08@gmail.com> wrote:
I wrote a simple client and server to get system information (e.g. cpu, memory, etc.) Client send 'cpu' to the server, then server will return cpu's information to client.
Now client send multiple commands to server one time, e.g. cpu, memory, database, hard disk. But sometimes server couldn't receive some type information (e.g. cpu, database), and the missed information type is not fixed every time.
So I want client to check whether ITransport.write() sends message to server successfully. If failed, client will resend the message to server.
It's a good thing that write() doesn't convey information about send() succeeding so you can't trust it :). You can't rely on send() succeeding to convey this information: send() can succeed but all that means is that data moved from your application into your kernel.
What you want to do is to have an application-level acknowledgement of the data that was sent.
AMP will provide this for you automatically; when the Deferred returned by callRemote fires, the other end has received and acknowledged the information.
-glyph
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
participants (2)
-
Glyph
-
Todong Ma