[Twisted-Python] can't get a simple client/server example to work!

bbxx789_05ss at yahoo.com bbxx789_05ss at yahoo.com
Wed May 13 02:08:28 EDT 2009

Here is the server code:-------------from twisted.internet.protocol import Protocol, Factoryfrom twisted.internet import reactorimport sys
class MyServer(Protocol):    def connectionMade(self):
factory = Factory()factory.protocol =  MyServer
reactor.listenTCP(2000, factory)

Here is the client code:--------------from twisted.internet.protocol import Protocol, ClientCreatorfrom twisted.internet import reactorimport sys
class MyClient(Protocol):    def dataReceived(self, data):        sys.stdout.write(data)        self.transport.loseConnection()------------
What do I need to add to the client code to make it connect to the server?  I think the "How To" documentation is woefully inadequate.  For instance, it says this:
----Here is a simple example:from twisted.internet.protocol import Protocol
from sys import stdout

class Echo(Protocol):
    def dataReceived(self, data):
Anyone who knows even a little bit of python should be able to recognize that that code does absolutely nothing.  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20090512/7ee49253/attachment.htm 

More information about the Twisted-Python mailing list