Thanks for your reply, Maarten. <br><br>I'm still chewing over it. In answer to your questions:<br><br>I will be sending short strings between client and server (bi-directionally) most of the time (> 100 times a day) and ocassionaly files (each of size 5 MB or less and > 10 but <100 times a day).
<br><br>I wouldn't mind sending strings or files along the same channel - but I don't know how to do that<br><br>While I like the brevity of python and realize that Twisted deffereds are the heart of the async model, I'm hampered by the scant documentation and code fragments.
<br><br>Could someone point me to how to send raw strings or binary files over the same channel and have the other side interpret the data correctly? <br><br>Thanks,<br><br>Sajit<br><br><div class="gmail_quote">On Dec 12, 2007 5:20 AM, Maarten ter Huurne <
<a href="mailto:maarten@treewalker.org">maarten@treewalker.org</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On Wednesday 12 December 2007, Sajit Rao wrote:
<br><br>> *The Goal:*<br><div class="Ih2E3d">><br>> - I'm trying to write a simple server/client app where the client can<br>> send the server either a small string like "hello" OR a small file
<br>> (txt, pdf, ppt,.. let's say < 5MB ).<br>> - The server needs to figure out if the data it received is a simple<br>> string or a file and symmetrically may decide to send back to the<br>> client a simple string or a small file.
<br>> - As a bonus, It's highly desirable that the transfer be secure - but<br>> it's ok for the first version if it isn't<br><br></div>Would an HTTP POST suffice? You could easily test it using a web browser or
<br>a program like wget and adding a secure channel is done by switching from<br>HTTP to HTTPS later.<br><br>If your application works like an instant messenger, consider using Twisted<br>Words, for example with the XMPP (Jabber) protocol.
<br><br>Does the client/server connection have to be able to pass a firewall or<br>proxy? In that case HTTP or something that can be run over HTTP would be a<br>big advantage.<br><br>> *Questions:*<br><div class="Ih2E3d">
><br>> What's the cleanest way to accomplish this? I've been looking at the<br>> single Howto/Example that exists for *twisted.conch* but still can't<br>> understand several things. In particular<br>
><br></div>> 1. Should I create two separate channels between server and client -<br><div class="Ih2E3d">> one for simple strings and one for files so that the client or server<br>> knows the type of data on that channel?
<br><br></div>That depends on what protocol you want to use over the channel(s). If the<br>protocol can send series of text strings and binaries over the same channel<br>then you need only one. But if having separate channels helps in
<br>simplifying the protocol, then that might be better.<br><br>One design decision to make is whether to keep the channel(s) open the whole<br>time or open them when there is new data and then close them when the<br>transfer is done. Or maybe keep the text string channel open all the time
<br>and open a file transfer channel on demand.<br><br>What kind of performance characteristics do you need? Does latency on the<br>text strings matter? Are you going to transfer 10 files a day or 10000?<br><br>> 2. Should the files be mime-encoded at one end and mime-decoded at the
<br><div class="Ih2E3d">> other so that file-type is automatically handled?<br><br></div>MIME encoding gives you a way to send the file name and type and it can be<br>used over a text stream. However, the encoding of the data itself is not
<br>really needed if your channel is 8-bit clear and everything except e-mail<br>is 8-bit clear nowadays (I think). For small files the overhead is neglible<br>though.<br><br>> 3. I've read that there is a python package called paramiko that
<br><div class="Ih2E3d">> implements ssh2 transfer - how does this compare with twisted.conch?<br><br></div>I don't know. One thing you could look at is which main loop you want to<br>use. If you want to use Twisted's reactor, conch would better integrate
<br>with that of course. But if you want to use a GUI toolkit not supported by<br>Twisted, it would take some effort to merge the main loops, so then running<br>paramiko in a thread might be easier.<br><br>Another thing to look at is the license: paramiko is LGPL, which places more
<br>restrictions on its use than Twisted's MIT license. Depending on your<br>situation that may or may not be important.<br><br>Bye,<br><font color="#888888"> Maarten<br></font></blockquote></div><br>