[Twisted-Python] Echo Server woes
So I've been playing with the examples on the Twisted website, mostly the Echo server. When it runs, it immediately echos back whatever character one types in. So the output looks like so: aakkee33ccbb::oo I wanted to rewrite it so that it would repeat things a line at a time, as opposed to a chracter at a time. After playing with the code and getting nowhere, someone on IRC helped me out by telling me I should use the LineReceiver class from twisted.protocols.basic. What has me stuck is trying to figure out how to use LineReceiver's dataReceived() method as opposed to the identically named one on the example page. I can't really figure out what class the example's dataReceived() method comes from. Thanks! :) Britt
You'd use lineReceived, check out how the finger protocol inherits from LineReceiver here: http://twistedmatrix.com/documents/current/howto/tutorial/intro On Wed, 4 Aug 2004 10:11:23 -0700 Britt Green <seamonkeys@gmail.com> wrote:
So I've been playing with the examples on the Twisted website, mostly the Echo server. When it runs, it immediately echos back whatever character one types in. So the output looks like so: aakkee33ccbb::oo
I wanted to rewrite it so that it would repeat things a line at a time, as opposed to a chracter at a time. After playing with the code and getting nowhere, someone on IRC helped me out by telling me I should use the LineReceiver class from twisted.protocols.basic. What has me stuck is trying to figure out how to use LineReceiver's dataReceived() method as opposed to the identically named one on the example page. I can't really figure out what class the example's dataReceived() method comes from.
Thanks! :)
Britt
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
--
That's perfect! Thanks! :) On Wed, 4 Aug 2004 12:57:21 -0500, John Babwell <johnbabwell@mailcan.com> wrote:
You'd use lineReceived, check out how the finger protocol inherits from LineReceiver here: http://twistedmatrix.com/documents/current/howto/tutorial/intro
On Wed, 4 Aug 2004 10:11:23 -0700
Britt Green <seamonkeys@gmail.com> wrote:
So I've been playing with the examples on the Twisted website, mostly the Echo server. When it runs, it immediately echos back whatever character one types in. So the output looks like so: aakkee33ccbb::oo
I wanted to rewrite it so that it would repeat things a line at a time, as opposed to a chracter at a time. After playing with the code and getting nowhere, someone on IRC helped me out by telling me I should use the LineReceiver class from twisted.protocols.basic. What has me stuck is trying to figure out how to use LineReceiver's dataReceived() method as opposed to the identically named one on the example page. I can't really figure out what class the example's dataReceived() method comes from.
Thanks! :)
Britt
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
--
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Britt Green wrote:
I wanted to rewrite it so that it would repeat things a line at a time, as opposed to a chracter at a time. After playing with the code and getting nowhere, someone on IRC helped me out by telling me I should use the LineReceiver class from twisted.protocols.basic. What has me stuck is trying to figure out how to use LineReceiver's dataReceived() method as opposed to the identically named one on the example page. I can't really figure out what class the example's dataReceived() method comes from.
LineReceiver inherits from Protocol. See : http://www.twistedmatrix.com/documents/current/api/twisted.internet.protocol... Both defines a method dataReceived(). You can also play around with LineReceiver's LineMode() and RawMode(). Try placing a print statement in your ||rawDataReceived| <http://www.twistedmatrix.com/documents/current/api/twisted.protocols.basic.LineReceiver.html#rawDataReceived>|() method (but remember to call superclass method LineReceiver.rawDataReceived() first) regards, Eugene =============================================== Reedflute Software Solutions Web -> www.reedflute.com ===============================================
Hi all, I have two twisted servers that send data to each other. Both servers are implemented as plugins, and created with mktap and started with twistd -f server.tap. My problem is that I need to have the first server call the second server on startup. In my servertap.py I have the following :- application = service.Application('feedserver', uid=1, gid=1) f = FeedService() serviceCollection = service.IServiceCollection(application) internet.TCPClient("localhost",pbport, f.getFactory()).setServiceParent(serviceCollection) f.start() return serviceCollection When I run mktap, the f.start() method is called, but when I actually run the server with twistd -f server.tap, this method does not get called. I need someway to kickstart the server to begin sending data to the receiving server. TIA John JT
participants (4)
-
Britt Green
-
Eugene Coetzee
-
John Babwell
-
John Toohey