[racket] Retrieving OS file handle from file ports

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Feb 2 01:11:18 EST 2015

The Racket C API provides

  intptr_t scheme_get_port_fd(Scheme_Object* port);

which you can access through the FFI:

 (require ffi/unsafe)

 (define scheme_get_port_fd
   (get-ffi-obj 'scheme_get_port_fd #f (_fun _racket -> _intptr)))

 (scheme_get_port_fd (current-output-port))

At Sun, 1 Feb 2015 21:48:26 +0100, Bartosz Przygoda wrote:
> Hello,
> 
> It is possible to communicate via serial port by using input/output ports.
> However, to achieve greater level of control, one needs to use other means
> - for linux systems one may want to use API defined in termios.h.
> 
> I wanted to use Racket FFI for those functions, however, they require file
> handle as parameter. Now, when I open port using open-input(-output)-port I
> receive Racket variable where the internal OS handle is hidden. What are
> the possibilities here? Is it possible to somehow grab file handle from
> input/output port structures?
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.