This is primarily Node.js question but it likely requires to be familiar with Win32 API and named pipes.
Node.js supports Windows named pipes for IPC connections. Here's an example:
// server.js
const server = require('net').createServer((socket) => {
socket.write('test\n');
socket.on('end', () => {
server.close();
});
});
server.listen('\\\\.\\\pipe\\\WinUAE');
It doesn't work when named pipe is connected by third-party client written in C++, this results in ERROR_INVALID_PARAMETER (code 87) error:
Connected to '\.\pipe\WinUAE'
SetNamedPipeHandleState failed err=87
And the snippet that causes the problem:
mode = PIPE_READMODE_MESSAGE;
if (!SetNamedPipeHandleState(p, &mode, NULL, NULL)) {
printf("SetNamedPipeHandleState failed err=%d\n", GetLastError());
return 0;
}
Client binary can be downloaded here, and the mirror in case of hosting problems.
I assume the problem is that Node.js doesn't fully support Windows named pipes and cannot be used for IPC in cases that demand first-class support like this one.
Is Node.js not suitable for IPC with such process? What is going on here under the hood?
PIPE_READMODE_MESSAGE- The function fails if this flag is specified for a byte-type pipe. - think you create exactly byte-type pipe -PIPE_TYPE_MESSAGEis not set. anyway your client code not need try setPIPE_READMODE_MESSAGEPIPE_READMODE_MESSAGE