[Twisted-Python] LineReceiver

"Einar S. Idsø" einar.twisted at norsk-esport.no
Mon Feb 26 05:57:18 EST 2007


Jean-Paul Calderone wrote:
> Also note that the default LineReceiver line delimiter is \r\n, not \n.

Lee,
If for some reason you need to transmit messages which include \r\n or
\n, then you can easily change the delimiter in your protocol to e.g.
"\x04" (EOT, End Of Transmission).

from twisted.protocols import basic
class MyLineReceiverProtocol(basic.LineReceiver):
    delimiter = "\x04"

Remember to perform this modification both clientside and serverside.

More info:
http://twistedmatrix.com/documents/current/api/twisted.protocols.basic.LineReceiver.html

There's also LineOnlyReceiver: "A protocol that receives only lines.
This is purely a speed optimisation over LineReceiver, for the cases
that raw mode is known to be unnecessary."
http://twistedmatrix.com/documents/current/api/twisted.protocols.basic.LineOnlyReceiver.html

Cheers,
Einar




More information about the Twisted-Python mailing list