English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] getting fd behind a channel from C
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-09-04 (08:30)
From: Olivier Andrieu <andrieu@i...>
Subject: Re: [Caml-list] getting fd behind a channel from C
 Jeremy Fincher [Tuesday 4 September 2001] :
 > I can't for the life of me figure out how, from C, to take an in_channel and
 > get the file descriptor of it.  How do I write a C function that takes an
 > in_channel and then does some work on the underlying file descriptor?

in the OCaml source tree, look at byterun/io.h : it contains
definitions and macros to access caml channels from C :

 - struct channel has a field fd for the file descriptor.
 - the macro Channel takes a Caml value and gives you a struct

so (Channel(ml_channel))->fd does what you want.

There's also the Unix.descr_of_in_channel and
Unix.descr_of_out_channel functions.

Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr