[REBOL] Re: The REBOL async:// tutorial - take 1
From: Christophe:Coussement:mil:be at: 4-Mar-2004 15:11
Hi Maarten,
I do not have very much experience when coming to network protocol, so please excuse
the triviality of my question :).
The fact is I could for sure use this 'async protocol for a project we are now developing.
I tried the following, but without any result. I try to load a %dghr.jpg file situated
in the same dir as %async-protocol, and try to connect to localhost. What did I wrong?
;>>>>>>>>>>>>>>>>>>> code ---
do %async-protocol.r
handler: func [
{ your comment here
RETURN: }
port [port!] "comment"
state [word! error!]
/local tmp cmd
][
;$debug/var/stop 'state
if error? :state [print mold disarm state return true]
switch state [
connect [
insert port {GET logo.jpg HTTP/1.0^M^JHost:127.0.0.1^M^J^M^J}
false
]
read [false]
write [false]
close [
data: copy port
close port
;$debug/var/stop 'data
data: to binary! find/tail data "^M^J^M^J"
other/image: attempt [load data]
other/text: ""
show other
false
]
]
]
port: open async://127.0.0.1:80
port/awake: :handler
view layout [
across me: box 100x100 random 255.255.255 0:00:0.5 feel [
engage: func [f a e][
if a = 'time [
me/color: random 255.255.255
show me
]
]
]
other: box 100x100 255.255.255 "Downloading image ..." return
area 208x100 "you can type here while downloading"
]
;--- code <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
TIA!
==christophe