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
AW: [Caml-list] Re: Select on channels (again)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-08-23 (07:03)
From: Christoph Bauer <christoph.bauer@l...>
Subject: AW: [Caml-list] Re: Select on channels (again)

> Why can't you just use the unix file opening functions since 
> you're using unix select? And if you need the ocaml in/out 
> channels, convert the unix file descriptors to ocaml ones 
> instead of the other way around. Seems simple enough to me.

I did this, but on windows with two programs communicating over
a pipe this isn't enough. select on windows and on a pipe doesn't
work. Therefore I wrote a stub for PeekNamedPipe():

#include <caml/unixsupport.h>
#include <windows.h>

CAMLprim value peeknamedpipe_stub( value fd ) {
  CAMLparam1( fd );
  DWORD available;
  if( !PeekNamedPipe( Handle_val( fd ), NULL, 0, NULL, &available, NULL ) )
    failwith( "peeknamedpipe failed");
  CAMLreturn( Val_int( available ) );

I use select on Unix and peednamedpipe on windows. 

Communication over sockets could be another solution, because then select
should work on windows, too.

Christoph Bauer