;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]

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

Reply via email to