[REBOL] Re: The REBOL async:// tutorial - take 1
From: maarten:vrijheid at: 4-Mar-2004 16:09
Hi Christophe,
>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.
>
Good.
>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?
>
What are you trying to do? Fetch the file from a file or a webserver?
>;>>>>>>>>>>>>>>>>>>> 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"
>
Do you receive data? What does your webserver log say?
> 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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>
It looks like you are re-using the exact code I mailed, which (I just
checked) works. So it looks like you'll have to debug using your
webserver and debugger in the script to see what gets done and what
doesn't. Sorry I can't help any more, but the code looks fine (an exact
copy of the sample code except for the URI).
--Maarten