Nonblocking sockets no longer raise a continuable exception when a

read or write operation would block.  Instead, they are schedules
with an event handler that `selects' on the pending file descriptors
and dispatches the appropriate callback.
This commit is contained in:
Abdulaziz Ghuloum
2008-03-23 02:14:00 -04:00
parent 6e599c4c72
commit 9aaf306f16
4 changed files with 127 additions and 23 deletions
+8 -15
View File
@@ -12,22 +12,15 @@
;;; it succeeds. Pretty lame at this point, but it works.
(define (http-cat host)
(with-exception-handler
(lambda (c)
;;; just return and let it retry until it succeeds
(print-condition c)
(unless (i/o-would-block-condition? c)
(raise c)))
(lambda ()
(let-values ([(op ip) (tcp-connect-nonblocking host "http")])
(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))))))
(let-values ([(op ip) (tcp-connect-nonblocking host "http")])
(let ([op (transcoded-port op (native-transcoder))]
[ip (transcoded-port ip (native-transcoder))])
(display "GET /\n" op)
(display (get-string-all ip))
(newline)
(close-input-port ip)
(close-output-port op))))
(http-cat "www.google.com")
(newline)
;(http-cat "127.0.0.1")