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
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