The specific example you try is a client that connects to a webserver to 
fetch the image. If you have no webserver running (no valid url...): no 
image!

async:// is just like tcp:// , but now with calllbacks instead of 
waiting yourself. Does this help you?

--Maarten

Coussement Christophe wrote:

> Hi Maarten and Will
> 
> Sorry for this late answer: I was out of office for a while...
> Thanks for helping me !
> 
> 
>>>I tried the following, but without any result. I try to load 
>>
>>a %logo.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?
> 
> 
> Fetch from the file.
> I just wanted to try the code running on localhost.
> 
> 
>>>;>>>>>>>>>>>>>>>>>>> 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?
> 
> 
> Well, do I have to work on a webserver?
> I thought %async-protocol.r serviced a sort of server, listening on specified port ?
> 
> 
>>>           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).
>>
> 
> 
> anyway, wet i get is the generated window, but with no image loading.
> After placing a debug mark at the beginning of 'handler, I can see the function 
> isn't evaluated once.
> I think I'm confused about the context of the use of this protocol :(
> Could you provide me with a concrete use case ?
> 
> TIA
> 
> ==christophe
> 
> 
> 
> 

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.

Reply via email to