A message for data waiting at a socket?
Doug Lerner
doug at webcrossing.com
Fri Jan 2 22:40:40 EST 2004
On 1/3/04 12:14 PM, "Dar Scott" <dsc at swcp.com> wrote:
>
> On Friday, January 2, 2004, at 07:43 PM, Doug Lerner wrote:
>
>> I am currently polling an open socket to check for data, or checking
>> for
>> data immediately after writing to the socket (to check for replies to
>> messages I send).
>>
>> But is there a message-driven way of doing this? Like if data is
>> waiting at
>> a socket (data pushed from a server) having it trigger a message, like
>> socketDataWaiting, or something like that?
>
> Yes.
>
> Use the "with message" option with the "read for socket" command.
>
> You specify the name of the handler. It is called with the socket ID
> and with the data in the buffer. (You do not look in "it".)
>
> You will need to arrange for multiple reads if needed.
>
> Dar Scott
Wouldn't that just signal a message when reading data from the socket is
complete?
What I mean is a message that would signal a handler to actually go ahead
and try the socket read - something that indicates that new data has arrived
at the socket basically.
Right now, what I do is:
(1) read socket immediately after a write socket (to check for immediate
replies to my write)
(2) use "send" to send a "refresh" message every few seconds to force the
write/read to take place (polling the socket)
What would be nicer though is if data were pushed from the other side (the
server I am connected to) to the socket that that would send a message to a
handler. That seems more dynamic and efficient and "in the spirit" of a
message-driven system. My app could then respond whenever data arrives.
Is there any message sent when data is pushed to a socket from the "other
side"?
doug
More information about the use-livecode
mailing list