Accessing DataSocket Server with Python

Chris Angelico rosuav at gmail.com
Fri May 29 10:46:35 EDT 2015


On Fri, May 29, 2015 at 11:37 PM, William Ray Wing <wrw at mac.com> wrote:
>> On May 28, 2015, at 6:17 PM, Dan Stromberg <drsalists at gmail.com> wrote:
>>
>> I have no idea about the protocol used by NI DataSockets, but you
>> might be able to reverse engineer the protocol by using the official
>> client with a sniffer.
>>
>> Also, be aware that TCP/IP guarantees that you get the correct data in
>> the correct order, but it doesn't guarantee anything about the sizes
>> of the chunks in which that data arrives.  So you could send 100
>> bytes, 100 bytes, 100 bytes, but on the other end receive 100 bytes,
>> 50 bytes, 75 bytes, 75 bytes.  When you catenate them all together,
>> it's still the same data though.
>>
>> HTH.
>>
>> On Wed, May 27, 2015 at 4:30 AM, Garrone, Corrado
>
> While that’s certainly possible in a routed network (and even then can be overridden with the “do not fragment” bit), it won’t happen in a LAN or self-contained instrument set-up.  These days, even routed networks tend to deliver anything less than a 1500 byte packet as a single entity.  With fiber backbones and high-speed LANs, it is more work for a router to fragment a packet then to simply pass it on.  The days of 480 byte packets pretty much went away with dial-up modems.
>

It's uncommon to receive 100, 50, 75, 75, to be sure, but it's
certainly possible for multiple writes to be gathered together into
single reads; there are buffers at both ends, and if there's any delay
anywhere, stuff can get combined while it's waiting. (Even stuff that
had previously been sent out as multiple packets, if the data has to
be re-sent, might get grouped.) So you still need to consider your
protocol to be a stream, and delimit messages explicitly rather than
depending on the length of a socket-read. Most of these kinds of
protocols seem to have some kind of message boundary system, though,
so this shouldn't be a problem. (I'm not familiar with DataSocket
itself, but I've used several others that are like that. Even
venerable TELNET effectively does - a "message" is a line of text, so
it's delimited by newline.)

ChrisA



More information about the Python-list mailing list