Connecting via named pipe from windows service (session#0) to desktop app (session #1)

An easier solution might be to use a WCF duplex contract with the Windows service hosting the WCF service. The client App would call an operation on the service to register itself, when it starts up. The Ping would then be an operation invoked periodically by the service on the client’s callback contract, to which … Read more

What is a good way to shutdown Threads blocked on NamedPipeServer#WaitForConnection?

This is cheesy, but it is the only method I have gotten to work. Create a ‘fake’ client and connect to your named pipe to move past the WaitForConnection. Works every time. Also, even Thread.Abort() did not fix this issue for me. _pipeserver.Dispose(); _pipeserver = null; using (NamedPipeClientStream npcs = new NamedPipeClientStream(“pipename”)) { npcs.Connect(100); }

Create Named Pipe C++ Windows

You cannot create a named pipe by calling CreateFile(..). Have a look at the pipe examples of the MSDN. Since these examples are quite complex I’ve quickly written a VERY simple named pipe server and client. int main(void) { HANDLE hPipe; char buffer[1024]; DWORD dwRead; hPipe = CreateNamedPipe(TEXT(“\\\\.\\pipe\\Pipe”), PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, // … Read more

What are named pipes?

Both on Windows and POSIX systems, named-pipes provide a way for inter-process communication to occur among processes running on the same machine. What named pipes give you is a way to send your data without having the performance penalty of involving the network stack. Just like you have a server listening to a IP address/port … Read more

IPC performance: Named Pipe vs Socket

Best results you’ll get with Shared Memory solution. Named pipes are only 16% better than TCP sockets. Results are get with IPC benchmarking: System: Linux (Linux ubuntu 4.4.0 x86_64 i7-6700K 4.00GHz) Message: 128 bytes Messages count: 1000000 Pipe benchmark: Message size: 128 Message count: 1000000 Total duration: 27367.454 ms Average duration: 27.319 us Minimum duration: … Read more

How to open a Windows named pipe from Java?

Use Named Pipes to Communicate Between Java and .Net Processes Relevant part in the link try { // Connect to the pipe RandomAccessFile pipe = new RandomAccessFile(“\\\\.\\pipe\\testpipe”, “rw”); String echoText = “Hello word\n”; // write to pipe pipe.write ( echoText.getBytes() ); // read response String echoResponse = pipe.readLine(); System.out.println(“Response: ” + echoResponse ); pipe.close(); } … Read more

Multiple pipes in subprocess

To emulate the bash process substitution: #!/usr/bin/env python from subprocess import check_call check_call(‘someprogram <(someprocess) <(anotherprocess)’, shell=True, executable=”/bin/bash”) In Python, you could use named pipes: #!/usr/bin/env python from subprocess import Popen with named_pipes(n=2) as paths: someprogram = Popen([‘someprogram’] + paths) processes = [] for path, command in zip(paths, [‘someprocess’, ‘anotherprocess’]): with open(path, ‘wb’, 0) as pipe: … Read more