On Apr 14, 2010, at 10:51 AM, vit...@synapticvision.com wrote:

> hi,
> is there any examples how to create (using Twisted)
> client that creates several TCP requests one after another and handle in
> asynch manner TCP responses for previous requests?
> Thanks.

twisted.protocols.amp and twisted.spread.pb both implement this.

In a nutshell: in connectionMade, initialize a dictionary on your protocol 
object mapping request IDs to Deferreds.  When you issue a request, make a new 
Deferred and put it into that dictionary.  When you receive a response, pop the 
Deferred out of that dictionary by looking up the key present in the response, 
and call its .callback() method.

Is that what you were looking for?
_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to