[Twisted-Python] Newbie question about writing a client

Hi, The echo client in doc/examples sends a hardcoded string from the call back "connectionMade". How can i change it to send any string produced by some other source ? For e.g., if i want to let the user enter some string and then send it to the echo server and then print the result back.
Thanks for any pointers, Anuj.
-------------------------------------------------------------------------------------
The information contained in this message is proprietary of Amdocs,
protected from disclosure, and may be privileged.
The information is intended to be conveyed only to the designated recipient(s)
of the message. If the reader of this message is not the intended recipient,
you are hereby notified that any dissemination, use, distribution or copying of
this communication is strictly prohibited and may be unlawful.
If you have received this communication in error, please notify us immediately
by replying to the message and deleting it from your computer.
Thank you.
---------------------------------------------------------

There are several ways. You can make the string global (probably not what you want). Or you can make it part of the Protocol class, and set it during the buildProtocol method in yoru factory. Or make it part of your factory and have the protocol use that. To do the last you coudl do something like:
f = EchoFactory() f.sayWhat = 'This is what I want to say' reactor.connectTCP(..., f)
Then your protocol can do: def connectionMade(..): self.transport.write(self.factor.sayWhat)
Hope that helps.
On Tue, 25 May 2004 12:12:43 +0300 "Anuj Seth" ANUJS@Amdocs.com wrote:
Hi, The echo client in doc/examples sends a hardcoded string from the call back "connectionMade". How can i change it to send any string produced by some other source ? For e.g., if i want to let the user enter some string and then send it to the echo server and then print the result back.
Thanks for any pointers, Anuj.
participants (2)
-
Anuj Seth
-
orbitz@ezabel.com