[plt-scheme] converting file descriptor from C FFI to Scheme port

From: Synx (plt at synx.us.to)
Date: Sat Dec 5 11:35:40 EST 2009

Neil Van Dyke wrote:
> When using the FFI, how to I turn a file descriptor produced by a C
> function into a Scheme input port (like "scheme_make_fd_input_port", but
> from Scheme rather than C)?
> 

(require scheme/foreign)

(unsafe!)

(define make-fd
  (get-ffi-obj "scheme_make_fd_input_port" #f
               (_fun _int _scheme _int _int -> _scheme)))

(make-fd (some-c-fd) "/dev/null" 0 0)


Posted on the users mailing list.