Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] /core async example

From: warp::reboot::ch at: 4-Mar-2004 15:52

;copy-paste this in console and you'll see who is faster! ;thanks to Gabriele, Marteen, Romano and Carl 8) do http://www.rebol.it/giesse/async-protocol.r get-fast: func [hosts /local port][ foreach host hosts [ uri: host port: open rejoin [async:// host ":80"] port/awake: do compose/deep handler ] until [wait .1 empty? system/ports/wait-list] ] handler: [ func [port [port!] state [word! error!]] [ if error? :state [print mold disarm state return true] switch state [ connect [ insert port rejoin [ {GET / HTTP/1.0} crlf {Host: } (uri) crlf crlf] false ] read [false] write [false] close [ data: copy port ;close port clear system/ports/wait-list print (uri) ;print find data join crlf crlf ;data: find/tail data join crlf crlf true ] ] ] ] ;example urls: [ "www.rebol.com" "www.rebol.net" "www.rebol.org" "www.apple.com" "www.oracle.com" "www.microsoft.com" ] loop 10 [get-fast urls]