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