[Twisted-Python] how to design protocol.
Let me explain my problem.. I am building an uploader application using twisted. I am using "Protocol" in both side. What is the best way to seperate data? When i try to call "self.transport.write(data)" it doesnt send data immediately, it is sending with some other datas whic i send them later. Why doesnt it send, what for is it waiting? when i some information data I am sending with '\n' (there is no other '\n' in my data) to separate it in the client side but it is getting really complicated. When i start to send file there is no problem, first send fileSize then read everything and write in a file till fileSize. I saw FileWrapper in the api but i couldnt find any tip that how it works, is it for sending file, is it right way to my goal? What about sending data like HTTP? What do you think about this way? 8 #bytes of data 11111111 #data 3 #bytes of data 111 #data 0 #finished sending data I need your suggestions all about these. (some links, documents, tips would be great) Thanks.. -- Aydın ŞEN Ege Üniversitesi Uluslararası Bilgisayar Enstitüsü
On Mon, 1 Dec 2008 15:19:47 +0200, Aydın ŞEN
Let me explain my problem.. I am building an uploader application using twisted. I am using "Protocol" in both side. What is the best way to seperate data? When i try to call "self.transport.write(data)" it doesnt send data immediately, it is sending with some other datas whic i send them later. Why doesnt it send, what for is it waiting?
http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#Whydoesittakealo...
when i some information data I am sending with '\n' (there is no other '\n' in my data) to separate it in the client side but it is getting really complicated. When i start to send file there is no problem, first send fileSize then read everything and write in a file till fileSize.
I'm not sure what problem you're describing.
I saw FileWrapper in the api but i couldnt find any tip that how it works, is it for sending file, is it right way to my goal?
No. FileWrapper probably isn't going to help you a lot. It's possible that twisted.protocols.basic.FileSender will.
What about sending data like HTTP? What do you think about this way? 8 #bytes of data 11111111 #data 3 #bytes of data 111 #data 0 #finished sending data
twisted.protocols.basic.NetstringReceiver (it can send too) might be useful.
I need your suggestions all about these. (some links, documents, tips would be great)
Jean-Paul
participants (2)
-
Aydın ŞEN
-
Jean-Paul Calderone