[Twisted-Python] sending file but LineReceiver doesnt run

Hi, I am trying to send file which is in the client's disk, i am using LineReceiver in the server side. I am sending and receiving data like login stuff but when i start to read & send file LineReceiver method doesnt run in the server side. Sending file code part is below, what can be cause of this? * i am reading 100 kb parts of file and send it, is it best choice? or reading file once and send it better? KB = 1024 * 100 while True: if (KB > file_size) | (KB == file_size): data = self.file.read(file_size) self.send_data(data) self.sended += file_size self.file.close() break else: data = self.file.read(KB) file_size -= KB self.send_data(data) self.sended += KB def send_data(self, data): self.transport.write(data + '\r\n') -- Aydın ŞEN Ege Üniversitesi Uluslararası Bilgisayar Enstitüsü

On Tue, 25 Nov 2008 12:41:46 +0200, Aydın ŞEN <adigeaydin@gmail.com> wrote:
Hi, I am trying to send file which is in the client's disk, i am using LineReceiver in the server side. I am sending and receiving data like login stuff but when i start to read & send file LineReceiver method doesnt run in the server side. Sending file code part is below, what can be cause of this?
File transfers are not best done using a line-oriented protocol. Have a look at the "Protocol Design" articles linked from <http://itamarst.org/>. Jean-Paul

Hello, On Tue, Nov 25, 2008 at 15:17, Jean-Paul Calderone <exarkun@divmod.com> wrote:
On Tue, 25 Nov 2008 12:41:46 +0200, Aydın ŞEN <adigeaydin@gmail.com> wrote:
Hi, I am trying to send file which is in the client's disk, i am using LineReceiver in the server side. I am sending and receiving data like login stuff but when i start to read & send file LineReceiver method doesnt run in the server side. Sending file code part is below, what can be cause of this?
The LineReceiver implements a limit of MAX_LENGTH = 16384 bytes per "line". When you send 100KB in a row, it calls it lineLengthExceeded() method and loses its connection...
File transfers are not best done using a line-oriented protocol. Have a look at the "Protocol Design" articles linked from <http://itamarst.org/>.
Jean-Paul
Indeed. -- Amaury Forgeot d'Arc

Thank you very much.. if i send file per 1KB does it cause lack of performance? 25 Kasım 2008 Salı 16:51 tarihinde Amaury Forgeot d'Arc <amauryfa@gmail.com>yazdı:
Hello,
On Tue, Nov 25, 2008 at 15:17, Jean-Paul Calderone <exarkun@divmod.com> wrote:
On Tue, 25 Nov 2008 12:41:46 +0200, Aydın ŞEN <adigeaydin@gmail.com> wrote:
Hi, I am trying to send file which is in the client's disk, i am using LineReceiver in the server side. I am sending and receiving data like login stuff but when i start to read & send file LineReceiver method doesnt
run
in the server side. Sending file code part is below, what can be cause of this?
The LineReceiver implements a limit of MAX_LENGTH = 16384 bytes per "line". When you send 100KB in a row, it calls it lineLengthExceeded() method and loses its connection...
File transfers are not best done using a line-oriented protocol. Have a look at the "Protocol Design" articles linked from <http://itamarst.org/>.
Jean-Paul
Indeed.
-- Amaury Forgeot d'Arc
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- Aydın ŞEN Ege Üniversitesi Uluslararası Bilgisayar Enstitüsü

On Tue, 25 Nov 2008 17:29:16 +0200, Aydın ŞEN <adigeaydin@gmail.com> wrote:
Thank you very much..
if i send file per 1KB does it cause lack of performance?
If you try to send a file like this, then any newlines it contains will be lost. Performance doesn't matter much if your results are wrong. You should not try to send a file with a line protocol. Read the "Protocol Design" articles linked from <http://itamarst.org/>. Jean-Paul

If you try to send a file like this, then any newlines it contains will be lost.
yeap, i got it what you mean..
Performance doesn't matter much if your results are wrong. You should not try to send a file with a line protocol. Read the "Protocol
reading.. thanks again -- Aydın ŞEN Ege Üniversitesi Uluslararası Bilgisayar Enstitüsü
participants (3)
-
Amaury Forgeot d'Arc
-
Aydın ŞEN
-
Jean-Paul Calderone