<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Wed, Dec 11, 2013 at 3:08 PM, Jean Dubois <span dir="ltr"><<a href="mailto:jeandubois314@gmail.com" target="_blank">jeandubois314@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I have an ethernet-rs232 adapter which allows me to connect to a measurement instrument by means of netcat on a linux system.<br>

e.g. entering nc 10.128.59.63 7000<br>
allows me to enter e.g.<br>
*IDN?<br>
after which I get an identification string of the measurement instrument back.<br>
I thought I could accomplish the same using the python module "socket"<br>
and tried out the sample program below which doesn't work however:<span class=""><font color="#888888"><br></font></span></blockquote><div><br></div><div>Sockets reserve the right to split one socket.send() into multiple socket.recv()'s on the other end of the communication, or to aggregate multiple socket.send()'s into a single socket.recv() - pretty much any way the relevant IP stacks and communications equipment feel like for the sake of performance or reliability.<br>
<br>The confusing thing about this is, it won't be done on every transmission - in fact, it'll probably happen rather seldom unless you're on a heavy loaded network or have some MTU issues (see Path MTU Discovery, and bear in mind that paths can change during a TCP session).  But writing your code assuming it will never happen is a bad idea.<br>
<br></div><div>For this reason, I wrote <a href="http://stromberg.dnsalias.org/~strombrg/bufsock.html">http://stromberg.dnsalias.org/~strombrg/bufsock.html</a> , which abstracts away these complications, and actually makes things pretty simple.  There are examples on the web page.<br>
<br></div><div>HTH<br><br></div></div></div></div>