r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3 Schemes] Implementors guide

Andreas
11-Jan-2010
[1024]
where the action occurs pertains to how the code is structured
Graham
11-Jan-2010
[1025]
ok, tcp port is good too .. I've always found the use of subport 
in r2 confusing ..
Andreas
11-Jan-2010
[1026x12]
true
i should've broken with that habit :)
so, to stop with this pollution of huge urls: http://bit.ly/7cflf4
and the flow up to "buffer USER" will be pretty much the same for 
each protocol that sends and initial welcome message
where the server sends an initial welcome message, that is
if the client is expected to send a request before receiving anything 
from the server, things will look different
the other design issue is wether the protocol should be sync or async 
for the user (i.e. the "script")
sync behaviour is depicted in this picture. basically each READ will 
WAIT on the tcp port until the response has fully arrived
if one would like to expose an async scheme, instead of the first 
WAIT, control will return to the script
ah, not really!
you'd return TRUE from the CONNECT event handler, and returns through 
all back to the script
i think the lookup should most of the time wrapped silently, and 
not asyncly exposed to a scheme's user, even if the scheme is supposed 
to be async
Graham
11-Jan-2010
[1038]
your pop scheme is sync ..
Andreas
11-Jan-2010
[1039x4]
yep
but i'd love to be provide an async mode as well
problem is: we can't truly do that yet
but that would be _my_ answer to your recent read/as concerns
Graham
11-Jan-2010
[1043]
I'm forcing sync by waiting until all the data has arrived
Andreas
11-Jan-2010
[1044x2]
so do i
foo: open ftp://.....

foo/awake: func [event] [ ... handle events like 'file-start, 'file-chunk, 
'file-end ..]
write foo [RETR %avatar.avi]
Graham
11-Jan-2010
[1046]
so what do we need ?  a thread that controls the awake handler?
Andreas
11-Jan-2010
[1047]
you see where i'm going with the above pseudocode?
Graham
11-Jan-2010
[1048]
and write returns immediately?
Andreas
11-Jan-2010
[1049]
precisely
Graham
11-Jan-2010
[1050]
So, does mine .. . but I have to kick it off with a wait
Andreas
11-Jan-2010
[1051x2]
wait foo
that's what i'd want
Graham
11-Jan-2010
[1053]
and now you're stuck ... waiting ...
Andreas
11-Jan-2010
[1054x2]
currently we have to do wait foo/..../subport, as far as i can tell
then, as far as i currently understand it, read foo should work
Graham
11-Jan-2010
[1056]
that's what my read does, it does a wait on the tcp port
Andreas
11-Jan-2010
[1057x5]
you'll have to "block" somewhere
the transfer won't happen in zero time
to indicate when it's fine to block: WAIT
but well, i don't think we can get that to work, at the moment
i'll have to experiment a bit more
Graham
11-Jan-2010
[1062]
so I can't return immediately from my read ... and let it download 
?
Andreas
11-Jan-2010
[1063x3]
somewhere you'll need something that blocks, yes
if you want to download while in the console, that could be a console 
background worker thread
if you want to download within a GUI app, that could be the GUI's 
main event loop
Graham
11-Jan-2010
[1066]
well, generally inside a gui .. so that's okay I guess.
Andreas
11-Jan-2010
[1067x2]
something that blocks: an event loop
i.e. something that checks all ports registered via read for incoming 
events, and dispatches events accordingly
Graham
11-Jan-2010
[1069]
so we add a gui event to the thing .. and we work inside of that
Andreas
11-Jan-2010
[1070x4]
fine for gui's, yes
shouldn't be bound to guis
R3 actually needs an event loop to work anyway
it's there on win32, not there on linux (yet)