named-pipes

duplex operation between two processes using named pipes in c#

这一生的挚爱 提交于 2019-12-05 07:06:42
I am trying to use named pipes to communicate between a server and a client process on the same machine. server sends a message to client, client does something with it and returns a result, and server is supposed to get the result. here is the code for server: using System; using System.IO; using System.IO.Pipes; class PipeServer { static void Main() { using (NamedPipeServerStream pipeServer = new NamedPipeServerStream("testpipe", PipeDirection.InOut)) { Console.WriteLine("NamedPipeServerStream object created."); // Wait for a client to connect Console.Write("Waiting for client connection..."

Named pipes server read timeout

时间秒杀一切 提交于 2019-12-05 04:12:40
When using C# NamedPipeServerStream, in case a client doesn't send any message-end-pattern (like \r\n when server reads with ReadLine()) NamedPipeServerStream Read methods will wait forever and no Abort() or Interupt() methods will work on that thread. Since: 1) Stream.ReadTimeout not supported for NamedPipeServerStream 2) Abort() or Interupt() doesn't work on thread 3) NamedPipeServerStream.Disconnect() nether work It is unclear, how to setup timeout on NamedPipeServerStream read operations? Let me introduce an example. The specification of IPC we have require an exchange of \0-terminated

Detect when reader closes named pipe (FIFO)

旧巷老猫 提交于 2019-12-05 03:50:00
Is there any way for a writer to know that a reader has closed its end of a named pipe (or exited), without writing to it? I need to know this because the initial data I write to the pipe is different; the reader is expecting an initial header before the rest of the data comes. Currently, I detect this when my write() fails with EPIPE . I then set a flag that says "next time, send the header". However, it is possible for the reader to close and re-open the pipe before I've written anything. In this case, I never realize what he's done, and don't send the header he is expecting. Is there any

Can I open a named pipe on Linux for non-blocked writing in Python?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 03:43:05
I created a fifo file using mkfifo . Is it possible to open/write to this without blocking? I'd like to be agnostic whether there is a reader or not. The following: with open('fifo', 'wb', 0) as file: file.write(b'howdy') Just stalls at the open until I do a cat fifo from another shell. I want my program to make progress regardless there's a data consumer watching or not. Is there a different linux mechanism I should be using perhaps? From man 7 fifo : A process can open a FIFO in nonblocking mode. In this case, opening or read-only will succeed even if no-one has opened on the write side yet,

How do I make named pipes work between c++ and .NET?

ε祈祈猫儿з 提交于 2019-12-05 02:28:05
问题 I just had a really tough time making Named Pipes work between c++ and .NET. I had no problems creating Named Pipes that worked between 2 c++ apps, or between 2 .NET apps. 回答1: I dont have problem with this communication, i use this scenario in some project. C++ side: LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\pipename"); CHAR chReadBuf[1024]; DWORD cbRead; BOOL fResult; fResult = CallNamedPipe( lpszPipename, // pipe name _Message, // message to server strlen(_Message), // message length

Named pipes performance issues

时间秒杀一切 提交于 2019-12-05 02:01:49
问题 I'm using named pipes for inter-procedural communication between C# and Delphi. C# uses the System.IO.Pipes package, whereas Delphi makes use of Libby's pipes.pas . Unfortunately, the communication is all but high-performance: Profiling showed me that the communication takes 72% of the whole runtime, the rest is used by calculations. I was able to locate one problem that could take up resources: If I don't explicitly disconnect the sending client's connection in Delphi, C# doesn't receive any

C# Sockets vs Pipes

前提是你 提交于 2019-12-05 01:12:05
Currently I am working on a multi-process desktop application on Windows. This application will be a shrink wrapped application which will be deployed on client machines across the world. While we can have broad specifications for the machines - e.g. Windows XP SP3 with .Net 4.0 CF, we wont have control over them and we cant be too specific on their configuration - e.g. we cannot specify the machine must have a cuda 1.4 capable graphic processor etc. Some of these processes are managed (.Net 4.0) and others are unmanaged (C++ Win32). The processes need to share data. The options I have

C#: Asynchronous NamedPipeServerStream The pipe is being closed exception

て烟熏妆下的殇ゞ 提交于 2019-12-05 01:01:59
问题 My previous question on the same theme: C#: Asynchronous NamedPipeServerStream understanding Now I have next: private void StartListeningPipes() { try { isPipeWorking = true; namedPipeServerStream = new NamedPipeServerStream(PIPENAME, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, BUFFERSIZE, BUFFERSIZE); Console.Write("Waiting for client connection..."); while(isPipeWorking) { IAsyncResult asyncResult = namedPipeServerStream.BeginWaitForConnection(this

Correcting out of order printing from stream redirection

送分小仙女□ 提交于 2019-12-04 18:44:51
I have a python script that uses multiprocessing.pool.map to do some work. As it goes it prints things to stdout , for errors it prints to stderr . I decided it would be nice to have a separate log file for each of the streams and after a bit of thinking worked out that I should run it like this: time ./ecisSearch.py 58Ni.conf 4 1 > >(tee stdout.log) 2> >(tee stderr.log >&2) This gives me the log files and preserves the output on the appropriate streams. However here comes the problem. If I run it without the redirects I get this: $ time ./ecisSearch.py 58Ni.conf 4 1 2015-01-09 14:42:37.524333

How do I call a WCF method from c++ using Named pipes?

允我心安 提交于 2019-12-04 18:28:22
问题 UPDATE: Looking through the protocol here, I can't figure out what goes into the Unsized Envelope Record. I can't find any examples online. ORIGINAL: I have the following WCF service static void Main(string[] args) { var inst = new PlusFiver(); using (ServiceHost host = new ServiceHost(inst, new Uri[] { new Uri("net.pipe://localhost") })) { host.AddServiceEndpoint(typeof(IPlusFive), new NetNamedPipeBinding(NetNamedPipeSecurityMode.None), "PipePlusFive"); host.Open(); Console.WriteLine(