Renamed fd->socket to port->socket and added better checking for being a socket.

This commit is contained in:
mainzelm 2001-06-20 16:12:40 +00:00
parent 8c724fb65f
commit dcc88cce36
2 changed files with 15 additions and 8 deletions

View File

@ -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

View File

@ -648,7 +648,7 @@
unix-address->socket-address
socket-address->unix-address
create-socket
fd->socket
port->socket
close-socket
bind-socket
connect-socket