From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Rottmann Newsgroups: gmane.lisp.guile.devel Subject: Re: Reading data from a file descriptor Date: Sun, 08 Nov 2015 00:49:01 +0100 Message-ID: <87fv0h1ic2.fsf@delenn.home.rotty.xx.vu> References: <87a8qpx2kg.fsf@elephant.savannah> <874mgxx1y3.fsf@elephant.savannah> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1446940165 5413 80.91.229.3 (7 Nov 2015 23:49:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 7 Nov 2015 23:49:25 +0000 (UTC) Cc: guile-devel@gnu.org To: Artyom Poptsov Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Nov 08 00:49:16 2015 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZvDER-0005UI-Na for guile-devel@m.gmane.org; Sun, 08 Nov 2015 00:49:15 +0100 Original-Received: from localhost ([::1]:45565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvDEQ-0002pb-Th for guile-devel@m.gmane.org; Sat, 07 Nov 2015 18:49:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvDEL-0002pV-Vu for guile-devel@gnu.org; Sat, 07 Nov 2015 18:49:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZvDEH-0002Bb-Qs for guile-devel@gnu.org; Sat, 07 Nov 2015 18:49:09 -0500 Original-Received: from mout.gmx.net ([212.227.15.18]:64388) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvDEH-00029x-Gp for guile-devel@gnu.org; Sat, 07 Nov 2015 18:49:05 -0500 Original-Received: from delenn.home.rotty.xx.vu ([85.127.106.102]) by mail.gmx.com (mrgmx003) with ESMTPSA (Nemesis) id 0LkgAG-1aTAT44BUq-00aRA4; Sun, 08 Nov 2015 00:49:03 +0100 Original-Received: by delenn.home.rotty.xx.vu (Postfix, from userid 1000) id 1F360320089; Sun, 8 Nov 2015 00:49:01 +0100 (CET) In-Reply-To: <874mgxx1y3.fsf@elephant.savannah> (Artyom Poptsov's message of "Sat, 07 Nov 2015 18:29:40 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-Provags-ID: V03:K0:OTPjnY2vnCcWp7liKOWhYksa/xsUZUTuAL4Zw/k/usa+wVMnAq1 5HBi0D4OS75Pl7Sxyxrt8/fmUt3HRAJeSsEmKVBkveadVOODCM/Nri5kIlj8mos0xX/7GLF VqzTTd0YdWTvMzPM/9vUZK1KGHul96u9s8fg/0OypJSQ1RPC3rVhMU1yREoYPAPwVki4D/p nioz6dRkM5cSt5u3irJ0g== X-UI-Out-Filterresults: notjunk:1;V01:K0:DzcbV+n+rYs=:wrXu83Ze4coOsTM7Pfe3D9 4XmguBzjrL+mMg6beKYrpJ/Xx3cX7gB6i54pKnjutDHpicfxrEiEHoubYX9e1aatnA09cEHia 7Zt3Ar2YJAFnnxk2qD5ngHJMeSHGotN4vt81pXk3LNp2VaaE0VPAwz45DEwhPkBxg7LbTOK93 82xEpewwKgsKk5w8x81yaC4dOpcnIG6sJN0v4kPtzjFpLblvnfUKVPOVN8LoG8xXcDJM6JoF1 nJWLasmyTzhnxG+aneo8L0L7KTQFV4xTqxibQ1KRW0lh2HlxLEjkkKdwCX/yTze1rAhu+jX90 hvn27r941H1Si2FgNNqWaGC6QthQYY5wpkcvGpp2u9xUes8EKRkTaWNB/0Q40LSrlVck3uFym G3pvHcxIVXQRpHvrm+X399CNhip2ZP4RAXBKAlusyufd5SQu9rcNhCZzy78nVGqpKIr7yHxBM B8KFTxa4BQdMGxnIPwcEq/Pn08xGP70yffjvDN4cK55QKw1oRjk79K2g31nrTuoOuS77/9x6R nx4J3avt74dTSTZQcMswZlRziVQ0GhzzEMzBRE8SldAHSPuouxTIrF0VAIIJbbfUc23ZUrHCa /J15I0R+XzDBYUgt1os4skmSAfocN4mi/ow5YkfKh8F7cA3fiPDocW7++bGpXQ4EAJUtVPa+s +94h/jQ5nwNWrCu/ZvilGI6MM4xOHxrkA+RkenWH9O+XRJWGJGG21JTnx8KcOfrMq3o+hMj5P 9L+if5OwgDfjsGwvijN5KPfF+rk5m2Da3Qm1iP6Hbo3qEtLZmT8pCTGvv3QDwp3PKqbOaXmu X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.18 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:18008 Archived-At: Artyom Poptsov 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 --