I have a Node.js application using Unix sockets which works on Linux, but I’m trying to make it work on Windows.
My socket has a name similar to C:\PathTo\socket.sock. The following code seems to work:
let addr = "C:\\PathTo\\socket.sock" in
let fd = Unix.socket PF_UNIX SOCK_STREAM 0 in
Unix.bind fd (ADDR_UNIX addr)
I can call Unix.listen and Unix.accept, and it seems to work and wait for clients.
However, when I try to connect from a Node.js client using that same address, I get an EACCES error, which led me to this StackOverflow question. It mentions part of the Node.js documentation:
On Windows, the local domain is implemented using a named pipe. The path must refer to an entry in
\\?\pipe\or\\.\pipe\.
I tried adding that prefix to the JS code that connects to the socket, but then I get a ENOENT error. And if I add the same prefix to the OCaml socket address, it fails with ENETDOWN when trying to do the bind.
Are there examples of such usage in Windows that work? I’m having a hard time identifying if the problem is related to Node.js, to OCaml’s implementation of Unix sockets, or some other Windows issue.