caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] [Question] Named pipe on Windows.
@ 2017-03-16  8:02 paul.lachat
  2017-03-16  8:23 ` Johannes Kanig
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: paul.lachat @ 2017-03-16  8:02 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 621 bytes --]

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. 

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

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. 

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

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. 

[-- Attachment #2: Type: text/html, Size: 821 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] [Question] Named pipe on Windows.
  2017-03-16  8:02 [Caml-list] [Question] Named pipe on Windows paul.lachat
@ 2017-03-16  8:23 ` Johannes Kanig
  2017-03-16  9:11 ` [Caml-list] " David Allsopp
  2017-03-16  9:37 ` [Caml-list] [Question] " David Scott
  2 siblings, 0 replies; 7+ messages in thread
From: Johannes Kanig @ 2017-03-16  8:23 UTC (permalink / raw)
  To: caml-list, paul.lachat

Hello Paul,

On Thu, 2017-03-16, 17:02:59, <paul.lachat@edu.univ-fcomte.fr> wrote:
> 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.
>
> But I can't find any module for Ocaml who allow using the system call of  
> Windows.
>
> 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.
>
> Does anybody know a way to use named pipe of Windows in Ocaml ?

For the client side, you can simply use Unix.openfile on the pipe name:

     let name = "\\\\.\\pipe\\" ^ socket_name in
     Unix.openfile name [Unix.O_RDWR] 0

For the server side, you need to call the Win32 API functions  
CreateNamedPipe and ConnectNamedPipe, and for that you need to have  
bindings in C, exactly like the above library does it. I don't think there  
is another way.

-- 
Johannes Kanig

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [Caml-list] Named pipe on Windows.
  2017-03-16  8:02 [Caml-list] [Question] Named pipe on Windows paul.lachat
  2017-03-16  8:23 ` Johannes Kanig
@ 2017-03-16  9:11 ` David Allsopp
  2017-03-16  9:37 ` [Caml-list] [Question] " David Scott
  2 siblings, 0 replies; 7+ messages in thread
From: David Allsopp @ 2017-03-16  9:11 UTC (permalink / raw)
  To: paul.lachat, caml-list

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] [Question] Named pipe on Windows.
  2017-03-16  8:02 [Caml-list] [Question] Named pipe on Windows paul.lachat
  2017-03-16  8:23 ` Johannes Kanig
  2017-03-16  9:11 ` [Caml-list] " David Allsopp
@ 2017-03-16  9:37 ` David Scott
  2017-03-16 12:09   ` Bikal Gurung
  2 siblings, 1 reply; 7+ messages in thread
From: David Scott @ 2017-03-16  9:37 UTC (permalink / raw)
  To: paul.lachat; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 1654 bytes --]

Hi,

On Thu, Mar 16, 2017 at 8:02 AM, <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.
>
> But I can't find any module for Ocaml who allow using the system call of
> Windows.
>
> 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.
>

Although I'm one of the authors of that particular library I now prefer to
use this other library instead:

https://github.com/fdopen/uwt
https://opam.ocaml.org/packages/uwt/

where "Uwt.Pipe" is a Unix domain socket on Unix and a named pipe on
Windows. I'm very happy with "uwt" -- it seems to be very stable and
reliable, despite the relatively low version number.

Personally I don't want my final executables to depend on the cygwin.dll
but I don't mind if my development environment uses cygwin for the Unix
utilities like "make", "vi" etc. I usually install OCaml one Windows using
this installer:

http://fdopen.github.io/opam-repository-mingw/installation/

-- this installs everything you need (including Cygwin). I then `opam
install` my dependencies and `make`, like I can on Unix. My resulting .exe
files are independent of cygwin.dll and I ship them as-is.

Hope this helps a little,

Dave


>
> Does anybody know a way to use named pipe of Windows in Ocaml ?
>
> 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.
>



-- 
Dave Scott

[-- Attachment #2: Type: text/html, Size: 3049 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] [Question] Named pipe on Windows.
  2017-03-16  9:37 ` [Caml-list] [Question] " David Scott
@ 2017-03-16 12:09   ` Bikal Gurung
  2017-03-16 13:54     ` David Allsopp
  0 siblings, 1 reply; 7+ messages in thread
From: Bikal Gurung @ 2017-03-16 12:09 UTC (permalink / raw)
  To: David Scott, paul.lachat; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 2161 bytes --]

With regards to ocaml on windows, has anyone tried using bash on windows
and ocaml built using msvc/mingw?
Bash on windows now supports calling native windows binaries from within
the bash shell itself.

https://msdn.microsoft.com/en-us/commandline/wsl/interop#invoking-windows-binaries-from-wsl

I am guessing this probably makes Cygwin redundant as a ocaml build
environment.

On Thu, 16 Mar 2017 at 09:38, David Scott <scott.dj@gmail.com> wrote:

> Hi,
>
> On Thu, Mar 16, 2017 at 8:02 AM, <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.
>
> But I can't find any module for Ocaml who allow using the system call of
> Windows.
>
> 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.
>
>
> Although I'm one of the authors of that particular library I now prefer to
> use this other library instead:
>
> https://github.com/fdopen/uwt
> https://opam.ocaml.org/packages/uwt/
>
> where "Uwt.Pipe" is a Unix domain socket on Unix and a named pipe on
> Windows. I'm very happy with "uwt" -- it seems to be very stable and
> reliable, despite the relatively low version number.
>
> Personally I don't want my final executables to depend on the cygwin.dll
> but I don't mind if my development environment uses cygwin for the Unix
> utilities like "make", "vi" etc. I usually install OCaml one Windows using
> this installer:
>
> http://fdopen.github.io/opam-repository-mingw/installation/
>
> -- this installs everything you need (including Cygwin). I then `opam
> install` my dependencies and `make`, like I can on Unix. My resulting .exe
> files are independent of cygwin.dll and I ship them as-is.
>
> Hope this helps a little,
>
> Dave
>
>
>
> Does anybody know a way to use named pipe of Windows in Ocaml ?
>
> 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.
>
>
>
>
> --
> Dave Scott
>

[-- Attachment #2: Type: text/html, Size: 5560 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [Caml-list] [Question] Named pipe on Windows.
  2017-03-16 12:09   ` Bikal Gurung
@ 2017-03-16 13:54     ` David Allsopp
  2017-03-18  2:24       ` Bikal Gurung
  0 siblings, 1 reply; 7+ messages in thread
From: David Allsopp @ 2017-03-16 13:54 UTC (permalink / raw)
  To: Bikal Gurung, David Scott, paul.lachat; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 3036 bytes --]

Yes – I had patched it for MSVC. The results are very good and at some point I’ll package it up properly for merging.

Note that the interop is trickier for the mingw ports because the resulting executables need to be able to call into LXSS. There’s also some pain with setting environment variables when calling Win32 processes, which is why I hadn’t got around to finishing it off.

Cygwin will only truly redundant if/when LXSS is available on all platforms – it’s only Windows 10 and not Server 2016 (to say nothing of older versions of Windows).


--dra

From: caml-list-request@inria.fr [mailto:caml-list-request@inria.fr] On Behalf Of Bikal Gurung
Sent: 16 March 2017 12:09
To: David Scott <scott.dj@gmail.com>; paul.lachat@edu.univ-fcomte.fr
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] [Question] Named pipe on Windows.

With regards to ocaml on windows, has anyone tried using bash on windows and ocaml built using msvc/mingw?
Bash on windows now supports calling native windows binaries from within the bash shell itself.

https://msdn.microsoft.com/en-us/commandline/wsl/interop#invoking-windows-binaries-from-wsl

I am guessing this probably makes Cygwin redundant as a ocaml build environment.

On Thu, 16 Mar 2017 at 09:38, David Scott <scott.dj@gmail.com<mailto:scott.dj@gmail.com>> wrote:
Hi,

On Thu, Mar 16, 2017 at 8:02 AM, <paul.lachat@edu.univ-fcomte.fr<mailto: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.

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

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.

Although I'm one of the authors of that particular library I now prefer to use this other library instead:

https://github.com/fdopen/uwt
https://opam.ocaml.org/packages/uwt/

where "Uwt.Pipe" is a Unix domain socket on Unix and a named pipe on Windows. I'm very happy with "uwt" -- it seems to be very stable and reliable, despite the relatively low version number.

Personally I don't want my final executables to depend on the cygwin.dll but I don't mind if my development environment uses cygwin for the Unix utilities like "make", "vi" etc. I usually install OCaml one Windows using this installer:

http://fdopen.github.io/opam-repository-mingw/installation/

-- this installs everything you need (including Cygwin). I then `opam install` my dependencies and `make`, like I can on Unix. My resulting .exe files are independent of cygwin.dll and I ship them as-is.

Hope this helps a little,

Dave


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

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.



--
Dave Scott

[-- Attachment #2: Type: text/html, Size: 10410 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] [Question] Named pipe on Windows.
  2017-03-16 13:54     ` David Allsopp
@ 2017-03-18  2:24       ` Bikal Gurung
  0 siblings, 0 replies; 7+ messages in thread
From: Bikal Gurung @ 2017-03-18  2:24 UTC (permalink / raw)
  To: David Allsopp; +Cc: David Scott, paul.lachat, caml-list

[-- Attachment #1: Type: text/plain, Size: 3444 bytes --]

That sounds promising. I look forward to your patch. :)

On Thu, Mar 16, 2017 at 1:54 PM, David Allsopp <dra-news@metastack.com>
wrote:

> Yes – I had patched it for MSVC. The results are very good and at some
> point I’ll package it up properly for merging.
>
>
>
> Note that the interop is trickier for the mingw ports because the
> resulting executables need to be able to call *into* LXSS. There’s also
> some pain with setting environment variables when calling Win32 processes,
> which is why I hadn’t got around to finishing it off.
>
>
>
> Cygwin will only truly redundant if/when LXSS is available on all
> platforms – it’s only Windows 10 and not Server 2016 (to say nothing of
> older versions of Windows).
>
>
>
>
>
> --dra
>
>
>
> *From:* caml-list-request@inria.fr [mailto:caml-list-request@inria.fr] *On
> Behalf Of *Bikal Gurung
> *Sent:* 16 March 2017 12:09
> *To:* David Scott <scott.dj@gmail.com>; paul.lachat@edu.univ-fcomte.fr
> *Cc:* caml-list@inria.fr
> *Subject:* Re: [Caml-list] [Question] Named pipe on Windows.
>
>
>
> With regards to ocaml on windows, has anyone tried using bash on windows
> and ocaml built using msvc/mingw?
>
> Bash on windows now supports calling native windows binaries from within
> the bash shell itself.
>
>
>
> https://msdn.microsoft.com/en-us/commandline/wsl/interop#
> invoking-windows-binaries-from-wsl
>
>
>
> I am guessing this probably makes Cygwin redundant as a ocaml build
> environment.
>
>
>
> On Thu, 16 Mar 2017 at 09:38, David Scott <scott.dj@gmail.com> wrote:
>
> Hi,
>
>
>
> On Thu, Mar 16, 2017 at 8:02 AM, <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.
>
> But I can't find any module for Ocaml who allow using the system call of
> Windows.
>
>
>
> 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.
>
>
>
> Although I'm one of the authors of that particular library I now prefer to
> use this other library instead:
>
>
>
> https://github.com/fdopen/uwt
>
> https://opam.ocaml.org/packages/uwt/
>
>
>
> where "Uwt.Pipe" is a Unix domain socket on Unix and a named pipe on
> Windows. I'm very happy with "uwt" -- it seems to be very stable and
> reliable, despite the relatively low version number.
>
>
>
> Personally I don't want my final executables to depend on the cygwin.dll
> but I don't mind if my development environment uses cygwin for the Unix
> utilities like "make", "vi" etc. I usually install OCaml one Windows using
> this installer:
>
>
>
> http://fdopen.github.io/opam-repository-mingw/installation/
>
>
>
> -- this installs everything you need (including Cygwin). I then `opam
> install` my dependencies and `make`, like I can on Unix. My resulting .exe
> files are independent of cygwin.dll and I ship them as-is.
>
>
>
> Hope this helps a little,
>
>
>
> Dave
>
>
>
>
> Does anybody know a way to use named pipe of Windows in Ocaml ?
>
> 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.
>
>
>
>
>
> --
>
> Dave Scott
>
>

[-- Attachment #2: Type: text/html, Size: 9318 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-03-18  2:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-16  8:02 [Caml-list] [Question] Named pipe on Windows paul.lachat
2017-03-16  8:23 ` Johannes Kanig
2017-03-16  9:11 ` [Caml-list] " David Allsopp
2017-03-16  9:37 ` [Caml-list] [Question] " David Scott
2017-03-16 12:09   ` Bikal Gurung
2017-03-16 13:54     ` David Allsopp
2017-03-18  2:24       ` Bikal Gurung

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