Introduced connect-socket-no-wait and connect-socket-successful?.

This commit is contained in:
mainzelm 2002-11-22 12:26:08 +00:00
parent b2f0570a86
commit 21364665ee
1 changed files with 25 additions and 19 deletions

View File

@ -216,7 +216,7 @@
;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;;; connect syscall ;;; connect syscall
;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
(define (connect-socket sock name) (define (connect-socket-no-wait sock name)
(cond ((not (socket? sock)) (cond ((not (socket? sock))
(error "connect-socket: socket expected ~s" sock)) (error "connect-socket: socket expected ~s" sock))
((not (socket-address? name)) ((not (socket-address? name))
@ -240,24 +240,30 @@
(socket-address:address name)))) (socket-address:address name))))
(if (car error?.einprogress?) (if (car error?.einprogress?)
(if (cdr error?.einprogress?) (if (cdr error?.einprogress?)
(begin #f
(select '#() (loop))
(vector (fdport-data:fd #t)))))))))
(fdport-data
(socket:outport sock)))) (define (connect-socket-successful? sock)
'#()) ;; If connect returned EINPROGRESS, we can check
;; If connect returned EINPROGRESS, we can check ;; it's success after the next success with getsockopt
;; it's success after the next success with getsockopt (zero? (socket-option sock level/socket socket/error)))
(let ((val (socket-option sock
level/socket (define (connect-socket sock name)
socket/error))) (let ((success? (connect-socket-no-wait sock name)))
(if (not (zero? val)) (cond ((not success?)
(errno-error val (select '#()
(errno-msg val) (vector (fdport-data:fd
%connect (fdport-data
sock (socket:outport sock))))
name)))) '#())
(loop))))))))))) (if (not (connect-socket-successful? sock))
(let ((errno (socket-option sock level/socket socket/error)))
(errno-error errno
(errno-msg errno)
%connect
sock
name)))))))
(import-os-error-syscall %connect (sockfd family name) "scheme_connect") (import-os-error-syscall %connect (sockfd family name) "scheme_connect")