1
我試圖http://www.mail-archive.com/[email protected]/msg19437.html無效端口規格(我剛換到www.reboltutorial.com):Rebol的多任務異步同:爲什麼會收到
do http://www.rebol.it/giesse/async-protocol.r
handler: func [port [port!] state [word! error!] /local tmp cmd] [
if error? :state [print mold disarm state return true]
switch state [
connect [
; do HTTP request
insert port {GET /files/2009/10/word.png HTTP/1.0^M^JHost:
www.reboltutorial.com^M^J^M^J}
false
]
read [false]
write [false]
close [
; get data
data: copy port
close port
;print copy/part data find data "^M^J^M^J"
data: to binary! find/tail data "^M^J^M^J"
other/image: attempt [load data]
other/text: ""
show other
false
]
]
]
port: open async://www.reboltutorial.com:80
port/awake: :handler
view layout [
across me: box 100x100 random 255.255.255 0:00:00.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."
]
]
但我發現了這個錯誤:
>> port: open async://reboltutorial.com:80
** Access Error: Invalid port spec: async://reboltutorial.com:80
** Near: port: open async://reboltutorial.com:80
>> port/awake: :handler
** Script Error: port has no value
** Near: port/awake: :handler
嗨格雷厄姆,非常感謝。 – 2010-06-12 15:58:46
我在這裏創建了一個GUI示例http://rebol.wik.is/Protocols/Test-async-http.r,您可以從http://github.com/gchiu/獲取更新的async-http.r Rebol2/blob/master/Protocols/prot-ahttp.r(注意名稱更改)。該示例使用進度表進行下載,並顯示正在下載的字符數。儘管沒有錯誤處理。 – 2010-06-12 22:26:01
嗨我試過了,並得到一個錯誤,請參閱 http://stackoverflow.com/questions/3076236/error-with-test-async-http-r-in-rebol – 2010-06-19 16:24:28