In RFC867/RFC868: work correctly if the remote server isn't there.

This commit is contained in:
sperber 2003-01-21 12:02:51 +00:00
parent 3c73d6a37f
commit e5d3139845
2 changed files with 28 additions and 9 deletions

View File

@ -46,10 +46,18 @@
(car (host-info:addresses hst-info))
(service-info:port srvc-info)))
(send-message socket "")
(select-ports timeout (socket:inport socket))
(let ((result (read-integer (socket:inport socket))))
(close-socket socket)
(- result 2208988800))))
(if (null? (select-ports timeout (socket:inport socket)))
(begin
(close-socket socket)
#f)
(with-fatal-error-handler*
(lambda (result punt)
;; we may see a "connection refused" error here
#f)
(lambda ()
(let ((result (read-integer (socket:inport socket))))
(close-socket socket)
(- result 2208988800)))))))
(define (rfc867-daytime/tcp host)
(let* ((hst-info (host-info host))
@ -74,10 +82,20 @@
(car (host-info:addresses hst-info))
(service-info:port srvc-info)))
(send-message socket "")
(select-ports timeout (socket:inport socket))
(let ((result (read-string 20 (socket:inport socket))))
(close-socket socket)
result)))
(if (null? (select-ports timeout (socket:inport socket)))
(begin
(close-socket socket)
#f)
(with-fatal-error-handler*
(lambda (result punt)
;; we may see a "connection refused" error here
#f)
(lambda ()
(call-with-values
(lambda () (receive-message socket 20))
(lambda (result socket-address)
(close-socket socket)
result)))))))
;; read 4 bytes from fd and build an integer from them
(define (read-integer fd)

View File

@ -453,7 +453,8 @@
(define-structures ((rfc867 rfc867-interface)
(rfc868 rfc868-interface))
(open scheme-with-scsh)
(open scheme-with-scsh
handle-fatal-error)
(files (lib nettime)))
(define-structure dns dns-interface