Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: -- (:)
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:  FAQ:
To unsubscribe, mail  Archives: