Socket read problems
Len Morgan
kttkinfo at gmail.com
Fri Oct 8 14:02:59 EDT 2010
Dar,
As it turns out, (and much to my embarrassment) you were close on your
first response: I was trying to read more bytes than were actually
there. The ModBus/TCP spec actually sends two length items. One is the
header + data length and the other is the data length only. What I was
doing was reading the former, then getting the actual data length, then
trying to read that many MORE bytes when I already had the data and
header in a variable.
It still bothers me though that I never got the socketTimeout message
even though that's exactly what was happening.
len morgan
On 10/8/2010 11:45 AM, Dar Scott wrote:
>
> On Oct 8, 2010, at 5:29 AM, Len Morgan wrote:
>
>> I wish it was that simple but the length of the message is only in
>> one byte so it's pretty hard to swap.
>
> Yeah, I guess the high byte is always zero.
>
> I never use read by number of bytes. It is not that I have seen
> problems with it, I just became comfortable doing things another way.
>
> I usually use 'read from <socket> with message <callback>'. I don't
> think the 'with message' is important for the behavior I see. This
> reads whatever is in the buffer. I think some people use an idiom of
> "for 0" in the command for this.
>
> I collect bytes into a buffer until there is a whole message and then
> pull that off, in a sense, doing myself what you are looking for
> LiveCode to do.
>
> You might be able to use 'read from <socket>' as a way to prevent the
> timeouts and to diagnose the problem. This will show if there are
> problems with the frame length.
>
> Dar Scott
>
>
>
>
>
> --
> **************************************
> Dar Scott
> Dar Scott Consulting and darzLAB
> 8637 Horacio Place NE
> Albuquerque, NM 87111
>
> Lab, office, home: +1 505 299 9497
> Fax: try 299-9497
> Skype/Google: lets set up a time
>
> http://www.swcp.com/dsc
> dsc at swcp.com
>
> Computer programming and tinkering
> **************************************
>
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
More information about the use-livecode
mailing list