I believe that Metacard had this useful option, which would read as many bytes as were ready without blocking. But the documentation says that the number of bytes has to be a positive integer. It still seems to work with 0,
reading however many bytes are ready without blocking. But is this really supported, and it will it be in future versions?
-John
read from socket socketID for 0
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
Hi John,
You could just use "until empty" instead - beware that if the connection encounters severe network congestion, the engine may be convinced that no more data is coming down the line.
So the best tactic is to setup a protocol where you have a 'header' section like HTTP where you read until two CRLF's come by, and make this header include the total length of the 'payload' section of your message.
Also, use the 'with message' style as often as you can, as it will keep your application responsive.
Hope this helped,
Jan Schenkel.
You could just use "until empty" instead - beware that if the connection encounters severe network congestion, the engine may be convinced that no more data is coming down the line.
So the best tactic is to setup a protocol where you have a 'header' section like HTTP where you read until two CRLF's come by, and make this header include the total length of the 'payload' section of your message.
Also, use the 'with message' style as often as you can, as it will keep your application responsive.
Hope this helped,
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
Unfortunately this doesn't work. I don't get to decide on the protocol - yes, it would be nice if it were http, because then I could scan for CR-LF, get chunked data with byte counts, etc. But the situation is that the data come in chunks whose size I do not know beforehand. The final chunk is terminated with an ACK.
Well, for now, "read from socket xxx for 0" seems to do what it always did in MetaCard, and I hope it stays that way: it returns whatever data are available, and goes on, without blocking. I run this in a loop with a 1 millisecond wait, and if I don't get a chunk with an ACK after a certain number of loops I bail. In this situation I do not want asynchronous reads using a message. It I can't get the data back pronto right there and then, we're in trouble and the telescope is going to shut down.
Well, for now, "read from socket xxx for 0" seems to do what it always did in MetaCard, and I hope it stays that way: it returns whatever data are available, and goes on, without blocking. I run this in a loop with a 1 millisecond wait, and if I don't get a chunk with an ACK after a certain number of loops I bail. In this situation I do not want asynchronous reads using a message. It I can't get the data back pronto right there and then, we're in trouble and the telescope is going to shut down.