[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 13:33:18 EDT 2009


Hi,



--- On Wed, 5/13/09, Adam <adam.bcn at gmail.com> wrote:

> From: Adam <adam.bcn at gmail.com>
> Subject: Re: [Twisted-Python] can't get a simple client/server example to work!
> To: "Twisted general discussion" <twisted-python at twistedmatrix.com>
> Date: Wednesday, May 13, 2009, 1:08 AM
> 2009/5/13 bbxx789_05ss at yahoo.com
> <bbxx789_05ss at yahoo.com>
> 
> 
> Here is the server
> code:-------------from
> twisted.internet.protocol import Protocol,
> Factoryfrom twisted.internet import
> reactorimport sys
> class MyServer(Protocol):
>     def connectionMade(self):
>       
>  self.transport.write("Hello")
> factory = Factory()factory.protocol =
>  MyServer
> reactor.listenTCP(2000, factory)
> 
> reactor.run()-----------
> 
> 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):
>        
> stdout.write(data)------
> Anyone who knows even a little bit of python
> should be able to recognize that that code does absolutely
> nothing.  
> 
> 
> Greetings nameless-and-frustrated Twisted beginner!  Have
> a look at the echoclient.py example, which you can download
> here:
> 
> http://twistedmatrix.com/projects/core/documentation/examples/index.html
> 
> 
> Essentially you also need to create an EchoFactory and set
> it to run within a reactor (notice that your server example
> already does this).
> 
> Hope that helps,
> 
> ~Adam
> 

I can't get anything to work.  I asked a simple question, but I can't seem to pry an answer out of this group, and the simple examples in the documentation are incomplete.  I've decided not to pursue Twisted any longer.  Don't bother responding.  I am unsubscribing.







      





More information about the Twisted-Python mailing list