caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Allsopp <dra-news@metastack.com>
To: "paul.lachat@edu.univ-fcomte.fr" <paul.lachat@edu.univ-fcomte.fr>,
	"caml-list@inria.fr" <caml-list@inria.fr>
Subject: RE: [Caml-list] Named pipe on Windows.
Date: Thu, 16 Mar 2017 09:11:45 +0000	[thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D90135AC75BA@Remus.metastack.local> (raw)
In-Reply-To: <1110622119.7945294.1489651379371.JavaMail.zimbra@edu.univ-fcomte.fr>

paul.lachat@edu.univ-fcomte.fr wrote:
> Hello,
>
> I need to setup communication between two Ocaml processes on Windows.
> I think that using the named pipe of Windows is the good method to do this task.

Depending on your exact needs, you can also accomplish this with anonymous pipes - use Unix.pipe (twice, if you need to communicate two ways) and pass the appropriate side of each pipe as stdin and stdout to Unix.create_process. That of course assumes that you can afford to use stdin/stdout for this. I don't think that the Unix module allows you to create inheritable handles, so I think that's the only way of passing the pipe descriptor without resorting to bindings.

> But I can't find any module for Ocaml who allow using the system call of Windows.

The traditional way is to create bindings in C for the system calls (see https://caml.inria.fr/pub/docs/manual-ocaml/intfc.html). The library you have found is certainly an example of doing this.

> I have already find this module https://opam.ocaml.org/packages/named-pipe/, but it use C,
> and I would like to avoid depending on another langage than Ocaml or software like Cygwin.

The OCaml runtime is implemented in C, so in some senses you can't avoid it! Note that Cygwin is in this context an operating system - you can bind to Windows system calls using stubs written in C and still not depend on Cygwin (if you use the Microsoft Visual C ports of OCaml, you don't even need Cygwin to compile your code). If you are using the actual Cygwin ports of OCaml, then although you can bind to Windows system calls, you shouldn't - you should use a normal Unix "file-based" pipe (see Unix.mkfifo).

> Does anybody know a way to use named pipe of Windows in Ocaml ?

The library you have found is the usual way - you may also like to investigate https://github.com/ocamllabs/ocaml-ctypes which, I believe has good Windows support these days (it's on my list of things to investigate and replace my own Windows C bindings...).

> Thank you in advance for your answer !
>
> Ps : Sorry if it's the wrong mailing list to ask, it's the first time I use one.

This was indeed the correct list, and a good question! Hope the answers help...


--dra

  parent reply	other threads:[~2017-03-16  9:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-16  8:02 [Caml-list] [Question] " paul.lachat
2017-03-16  8:23 ` Johannes Kanig
2017-03-16  9:11 ` David Allsopp [this message]
2017-03-16  9:37 ` David Scott
2017-03-16 12:09   ` Bikal Gurung
2017-03-16 13:54     ` David Allsopp
2017-03-18  2:24       ` Bikal Gurung

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E51C5B015DBD1348A1D85763337FB6D90135AC75BA@Remus.metastack.local \
    --to=dra-news@metastack.com \
    --cc=caml-list@inria.fr \
    --cc=paul.lachat@edu.univ-fcomte.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).