Problem with "read from socket"
maxence.bernard at ensi-bourges.fr
maxence.bernard at ensi-bourges.fr
Tue Jun 29 06:00:03 EDT 2004
>>> Your script is waiting for two bytes.
>>
>> So, is there a way to stop this waiting, otherwise my application
>> doesn't
>> continue. How could I interrupt the "read from socket" instruction with
>> the socketTimeout message ?
>
> First, I need to say that I rarely use socket I/O without "with
> message", so I may be off here.
>
> One way is to switch to the "with message" style, which can be wordy
> and breaks up your logic and thus can be awkward. Even so, I recommend
> this.
>
> The other method is to use "until empty" which will give you whatever
> is in the buffer and will return immediately. I mentioned that in mail
> I just sent.
>
> (One might guess it will return empty every time since it will match
> empty at the start of the buffer, but that is not the case. One might
> guess that it will wait until the other end closes since empty is said
> to be equivalent to eof, but that is not the case either.)
I cannot change my algorithm to put "with message" and even "until empty",
because I will lose data.
Actually, with the instructions :
on socketTimeout
answer "hello"
end socketTimeout
function fn
...
read from socket socket1 for 2
...
end fn
The socketTimeout message never executes, because the message box never
appears. So the problem is not that the program waits for the 2 bytes. In
fact, the program seems to stop, and the strange thing is that it always
restart when I move the mouse on the card. Is that a bug? How could I
solve this ?
Maxence BERNARD
More information about the use-livecode
mailing list