I am working on an inter-process communication between a .net (v4.5.2) and Javascript node.js (v8.9.0) application. I want to use Windows named pipes for this (and only named pipes). For the Javascript application, I am using the named-pipes package (v0.0.1) I am able to establish a connection between the two applications which tells me that I am not completely off base here. I would expect to see the data event being triggered in the JavaScript application whenever I am writing a string to the NamedPipeServerStream but no data is received. I can not receive any data. Here is the code for .net and the JavaScript application. Any ideas why the data event is not being triggered?
.Net Code
using System;
using System.IO;
using System.IO.Pipes;
namespace NamedPipes
{
class Program
{
static void Main(string[] args)
{
var server = new NamedPipeServerStream("XYZNamedPipe");
Console.WriteLine("Waiting for Connection");
server.WaitForConnection();
Console.WriteLine("Connection Established");
StreamWriter writer = new StreamWriter(server);
int cnt = 0;
while (true)
{
string line = Console.ReadLine();
writer.WriteLine(++cnt.ToString() + ": " + line);
}
}
}
}
JavaScript Code
var NamedPipes = require("named-pipes");
pipe = NamedPipes.connect('XYZNamedPipe')
pipe.on('connect', (str) => {
console.log('connection established');
});
pipe.on('data', (str) => {
console.log('data received');
console.log(str);
});
pipe.on('end', (str) => {
console.log('end');
});