What is the difference between twisted.protocols.basic.LineReceiver and twisted.internet.protocol.Protocol?

For a typical client-server based application, how do the two differ from each other. Specifically, what is special with a line-based protocol? Even better, when does a class have to inherit from Protocol and when from LineReceiver?

Answers


Difference becomes by received data handling.

Protocol have dataReceived function. It will be called whenever data received.

LineReceiver overrides Protocol. It is implements a basic messaging format that messages separated with ' \r\n'.

Let's assume server writes messages like;

request.write("Lorem ipsum")
request.write("do amet siempre.\r\n")
request.write("We have Drogba!\r\n")

Messaged received on the Client side with implements Protocol;

def dataReceived(self, data):
   print data
.
.
output:

Lorem ipsum
do amet siempre.
We have Drogba!

Messaged received on the Client side with implements LineReceiver;

def lineReceived(self, line):
   print line
.
.
output: 
Lorem ipsum do amet siempre.
We have Drogba!

I hope it is helpful. For more information you can look reference or comment to ask.


Need Your Help

I want to remove an element but the click () does not work

javascript jquery html5

I want to click .close to remove .status-profile but click() does not work.