I don't want "read from socket" to be blocking
Rob Cozens
rcozens at pon.net
Thu Jul 31 22:35:00 EDT 2003
>I use read socket to access a pop3 server (email) I need to repeat
>certain commands several times. How can I make them non-blocking
>while still repeating them?
Add a callBackMessage, Björnke,
Rev Dictionary:
If you specify a callbackMessage, the message is sent to the object
whose script contains the read from socket command, as soon as the
read is finished. This message has two parameters: the socketID and
the data received from the socket.
If you don't specify a callbackMessage, the handler pauses until the
read has been completed, or until the time set in the
socketTimeoutInterval property has passed.
Here is an example from Jan Schenkel's libSTAMP.rev:
------------------------------------------------------------------------------------------
-- HANDLER : libSTAMP_sendConnectionID
-- PARAMETERS : pSocket = the socket of the target service point
-- PURPOSE : send the local connection ID and awaits the remote
connection ID
------------------------------------------------------------------------------------------
on libSTAMP_sendConnectionID pSocket
add 1 to sNumOfRemoteServicePoints
write ("100" && "MY-CONNECTION-ID=" & sNumOfRemoteServicePoints &
return) to socket pSocket
put sNumOfRemoteServicePoints into sRemoteServicePoints[pSocket,"LOCAL"]
read from socket pSocket for 1 line with message "libSTAMP_readConnectionID"
end libSTAMP_sendConnectionID
------------------------------------------------------------------------------------------
-- HANDLER : libSTAMP_readConnectionID
-- PARAMETERS : pSocket = the socket of the target service point
-- PURPOSE : read the remote connection ID and start the
connection check loop
------------------------------------------------------------------------------------------
on libSTAMP_readConnectionID pSocket, pData
[snip]
end libSTAMP_readConnectionID
--
Rob Cozens
CCW, Serendipity Software Company
http://www.oenolog.com/who.htm
"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."
from "The Triple Foole" by John Donne (1572-1631)
More information about the use-livecode
mailing list