Socket read problems

Dar Scott dsc at swcp.com
Fri Oct 8 01:42:47 EDT 2010


Could you have gotten the two length bytes swapped and are asking for  
way too many bytes?

Dar Scott

On Oct 7, 2010, at 6:22 PM, Len Morgan wrote:

>  I'm trying to read data from a MODBus/TCP controller and having  
> some issues with the timing of the read command.  I request a block  
> of registers from the slave and it returns the requested bytes and  
> header just fine and very quickly.  In order to read everything  
> right, I have to first read the first 6 bytes of the header to know  
> how many bytes are to follow.  Once I know that, I do a read from  
> socket tSock for <bytes> characters.  Note that ALL of the  
> characters have been received in a single packet so once I read the  
> 6 bytes, the rest of the data is already in the socket buffer.
>
> The problem I have is when I do the second read, the read command  
> blocks for the socketTimeoutInterval before continuing.  It doesn't  
> matter what I set it to, it will wait that long before continuing.   
> I tried catching the socketTimeout message but that message is  
> never sent, even when I set the socketTimeoutInterval to 5  
> milliseconds!
>
> I am not using the read ... with message form of the command since  
> I want the handler to wait until all the bytes have been received  
> before I move on.  Has anyone else seen this?  Have I missed  
> something in the documentation or could this be something in the  
> Windows code that handles sockets?
>
> Any help would be appreciated!
>
> len morgan
> _______________________________________________
> 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