2007-12-26 17:35:58 -05:00
|
|
|
#!/usr/bin/env scheme-script
|
|
|
|
|
|
|
|
(import (ikarus))
|
|
|
|
|
|
|
|
;;; very simple demo for how to connect to a server,
|
|
|
|
;;; send a request and receive a response.
|
|
|
|
|
|
|
|
(define (http-cat host)
|
2009-06-26 05:04:39 -04:00
|
|
|
(let-values ([(ip op) (tcp-connect host "http")])
|
2007-12-26 17:35:58 -05:00
|
|
|
(let ([op (transcoded-port op (native-transcoder))]
|
|
|
|
[ip (transcoded-port ip (native-transcoder))])
|
|
|
|
(display "GET /\n" op)
|
|
|
|
(display (get-string-all ip))
|
|
|
|
(close-input-port ip)
|
|
|
|
(close-output-port op))))
|
|
|
|
|
2007-12-27 22:08:27 -05:00
|
|
|
(http-cat "www.google.com")
|
|
|
|
(newline)
|
|
|
|
;(http-cat "127.0.0.1")
|
2007-12-26 17:35:58 -05:00
|
|
|
|