Renamed fd->socket to port->socket and added better checking for being a socket.
This commit is contained in:
parent
8c724fb65f
commit
dcc88cce36
|
@ -169,14 +169,21 @@
|
|||
|
||||
|
||||
;;; Turn a file descriptor into a socket.
|
||||
;;; Useful if running as inetd-child
|
||||
|
||||
(define (fd->socket fd pf)
|
||||
(let* ((in (make-input-fdport fd 0))
|
||||
(out (dup->outport in)))
|
||||
(set-fdes-status fd open/non-blocking) ; this raises an error if fd was not
|
||||
; a socket
|
||||
(set-fdes-status out open/non-blocking)
|
||||
(define (port->socket port pf)
|
||||
;;; ensure underlying fd is a socket by a random getsockopt call
|
||||
(if (not (port? port))
|
||||
(error "first argument to port->socket is not a port" port))
|
||||
(sleazy-call/fdes
|
||||
port
|
||||
(lambda (fd)
|
||||
(%getsockopt fd level/socket socket/debug)))
|
||||
(let ((in (if (input-port? port)
|
||||
port
|
||||
(dup->inport port)))
|
||||
(out (if (output-port? port)
|
||||
port
|
||||
(dup->outport port))))
|
||||
(make-socket pf in out)))
|
||||
|
||||
(define-foreign %socket/errno
|
||||
|
|
|
@ -648,7 +648,7 @@
|
|||
unix-address->socket-address
|
||||
socket-address->unix-address
|
||||
create-socket
|
||||
fd->socket
|
||||
port->socket
|
||||
close-socket
|
||||
bind-socket
|
||||
connect-socket
|
||||
|
|
Loading…
Reference in New Issue