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
[1045]
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
[1070x5]
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)
btw, here's the source link to the pop3 seq diagram: http://bit.ly/4q0ADG
Graham
11-Jan-2010
[1075]
One good thing .. on r2 I doubt I could download a 500Mb file using 
ftp .. but I'm nearly there now and the windows task manager is only 
showing 12Mb of ram usage with 0-1 % cpu
Andreas
11-Jan-2010
[1076]
very nice
Graham
11-Jan-2010
[1077]
We need some standard network error handlers too .. like if the password 
is wrong etc.
Andreas
11-Jan-2010
[1078x2]
the other, more traditional approach, would be something around copy/part
(for your data streaming question)
Graham
11-Jan-2010
[1080]
except the r2 ftp scheme doesn't support that ... AFAIK
Andreas
11-Jan-2010
[1081x4]
ftp: open ftp://...
write/append %... copy/part ftp 10240
don't care about R2 :)
(I don't)
wrap a `while [not tail? ftp] [....]` around this
Graham
11-Jan-2010
[1085]
My issue with the schemes is that the interface to them was always 
too restricted ...
Andreas
11-Jan-2010
[1086]
yeah. don't know if that's even possible in R3 at the moment
Graham
11-Jan-2010
[1087]
so we had to hack the schemes to add eg. 'TOP in r2 prot-pop
Andreas
11-Jan-2010
[1088]
i think a COPY actor will be there, but i guess tail? won't
Graham
11-Jan-2010
[1089]
so instead of directly interacting with the scheme, we need an intermediate 
level ...
Andreas
11-Jan-2010
[1090x3]
tough issues
what would you like the error handler to do in case the password 
is wrong?
just raise some standardised error!?
Graham
11-Jan-2010
[1093x2]
yeah ...
I just use Gabriele's http-error ...