BIND-LISTEN-ACCEPT-LOOP: Close the socket when interrupted.

This commit is contained in:
uid35759 2001-07-04 11:54:41 +00:00
parent 9db99b091c
commit 7228fc0e82
1 changed files with 18 additions and 8 deletions

View File

@ -86,14 +86,24 @@
(set-socket-option sock level/socket socket/reuse-address #t) (set-socket-option sock level/socket socket/reuse-address #t)
(bind-socket sock addr) (bind-socket sock addr)
(listen-socket sock 5) (listen-socket sock 5)
(let loop () (call-with-current-continuation
(with-errno-handler (lambda (exit)
;; ECONNABORTED we just ignore (with-handler
((errno packet) ((errno/connaborted) (loop))) (lambda (condition more)
(call-with-values (with-handler
(lambda () (accept-connection sock)) (lambda (condition ignore) (more))
proc) (lambda () (close-socket sock)))
(loop))))) (exit 'interrupted))
(lambda ()
(let loop ()
(with-errno-handler
;; ECONNABORTED we just ignore
((errno packet)
((errno/connaborted) (loop)))
(call-with-values
(lambda () (accept-connection sock))
proc)
(loop)))))))))
;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;;; Socket Record Structure ;;; Socket Record Structure