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.
|
;;; Turn a file descriptor into a socket.
|
||||||
;;; Useful if running as inetd-child
|
|
||||||
|
|
||||||
(define (fd->socket fd pf)
|
(define (port->socket port pf)
|
||||||
(let* ((in (make-input-fdport fd 0))
|
;;; ensure underlying fd is a socket by a random getsockopt call
|
||||||
(out (dup->outport in)))
|
(if (not (port? port))
|
||||||
(set-fdes-status fd open/non-blocking) ; this raises an error if fd was not
|
(error "first argument to port->socket is not a port" port))
|
||||||
; a socket
|
(sleazy-call/fdes
|
||||||
(set-fdes-status out open/non-blocking)
|
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)))
|
(make-socket pf in out)))
|
||||||
|
|
||||||
(define-foreign %socket/errno
|
(define-foreign %socket/errno
|
||||||
|
|
|
@ -648,7 +648,7 @@
|
||||||
unix-address->socket-address
|
unix-address->socket-address
|
||||||
socket-address->unix-address
|
socket-address->unix-address
|
||||||
create-socket
|
create-socket
|
||||||
fd->socket
|
port->socket
|
||||||
close-socket
|
close-socket
|
||||||
bind-socket
|
bind-socket
|
||||||
connect-socket
|
connect-socket
|
||||||
|
|
Loading…
Reference in New Issue