Thanks for your reply, Maarten. <br><br>I&#39;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 (&gt; 100 times a day) and ocassionaly files (each of size 5 MB or less and &gt; 10 but &lt;100 times a day).
<br><br>I wouldn&#39;t mind sending strings or files along the same channel - but I don&#39;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,&nbsp; I&#39;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 &lt;
<a href="mailto:maarten@treewalker.org">maarten@treewalker.org</a>&gt; 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>&gt; *The Goal:*<br><div class="Ih2E3d">&gt;<br>&gt; &nbsp; &nbsp;- I&#39;m trying to write a simple server/client app where the client can<br>&gt; &nbsp; &nbsp;send the server either a small string like &quot;hello&quot; OR a small file
<br>&gt; (txt, pdf, ppt,.. let&#39;s say &lt; 5MB ).<br>&gt; &nbsp; &nbsp;- The server needs to figure out if the data it received is a simple<br>&gt; &nbsp; &nbsp;string or a file and symmetrically may decide to send back to the<br>&gt; client a simple string or a small file.
<br>&gt; &nbsp; &nbsp;- As a bonus, It&#39;s highly desirable that the transfer be secure - but<br>&gt; &nbsp; &nbsp;it&#39;s ok for the first version if it isn&#39;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>&gt; *Questions:*<br><div class="Ih2E3d">
&gt;<br>&gt; What&#39;s the cleanest way to accomplish this? I&#39;ve been looking at the<br>&gt; single Howto/Example that exists for *twisted.conch* but still can&#39;t<br>&gt; understand several things. In particular<br>
&gt;<br></div>&gt; &nbsp; &nbsp;1. Should I create two separate channels between server and client -<br><div class="Ih2E3d">&gt; &nbsp; &nbsp;one for simple strings and one for files so that the client or server<br>&gt; 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>&gt; &nbsp; &nbsp;2. Should the files be mime-encoded at one end and mime-decoded at the
<br><div class="Ih2E3d">&gt; &nbsp; &nbsp;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>&gt; &nbsp; &nbsp;3. I&#39;ve read that there is a python package called paramiko that
<br><div class="Ih2E3d">&gt; &nbsp; &nbsp;implements ssh2 transfer - how does this compare with twisted.conch?<br><br></div>I don&#39;t know. One thing you could look at is which main loop you want to<br>use. If you want to use Twisted&#39;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&#39;s MIT license. Depending on your<br>situation that may or may not be important.<br><br>Bye,<br><font color="#888888"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Maarten<br></font></blockquote></div><br>