[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reading data from a file descriptor
From: |
Andreas Rottmann |
Subject: |
Re: Reading data from a file descriptor |
Date: |
Sun, 08 Nov 2015 00:49:01 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Artyom Poptsov <address@hidden> writes:
> Oh sorry, there was a mistake in my previous mail. 'scm_i_fdes_to_port'
> is an internal procedure, but 'scm_fdes_to_port' is defined as Guile API
> and should be available to Guile programs. Here's its definition:
>
> SCM
> scm_fdes_to_port (int fdes, char *mode, SCM name)
>
> And the commentary that I quoted really applies to 'scm_fdes_to_port',
> not to 'scm_i_fdes_to_port'.
>
Also note that if there's no requirement to actually implement this in
C, there's `fdes->inport' and `fdes->outport' on the Scheme level, so
something like the following would be analogous to the C example code
posted:
(import (ice-9 binary-ports))
(define (process-fd fd)
(let ((port (fdes->inport fd)))
(display "read: ")
(display (get-bytevector-n port 100))
(display "\n")))
(process-fd (acquire-valid-fd))
You could now just implement `acquire-valid-fd' in C and expose it to
Scheme, if that is even necessary. If you have the FD available via
e.g. an environment variable, `acquire-valid-fd' can be implemented in
Scheme as well.
Regards, Rotty
--
Andreas Rottmann -- <http://rotty.xx.vu/>
- Reading data from a file descriptor, Jan Synáček, 2015/11/07
- Re: Reading data from a file descriptor, Artyom Poptsov, 2015/11/07
- Re: Reading data from a file descriptor, Artyom Poptsov, 2015/11/07
- Re: Reading data from a file descriptor,
Andreas Rottmann <=
- Re: Reading data from a file descriptor, Jan Synáček, 2015/11/09
- Re: Reading data from a file descriptor, Mark H Weaver, 2015/11/13
- Re: Reading data from a file descriptor, Jan Synáček, 2015/11/13
- Re: Reading data from a file descriptor, Thompson, David, 2015/11/13
- Re: Reading data from a file descriptor, Jan Synáček, 2015/11/16
- Re: Reading data from a file descriptor, Thompson, David, 2015/11/16
- Re: Reading data from a file descriptor, Amirouche Boubekki, 2015/11/16
- Re: Reading data from a file descriptor, tomas, 2015/11/17
- Re: Reading data from a file descriptor, Chris Vine, 2015/11/17
- Re: Reading data from a file descriptor, tomas, 2015/11/17