named-pipes

read not blocking on named pipe

╄→尐↘猪︶ㄣ 提交于 2020-01-01 08:46:57
问题 i have the following bit of C code which reads from a pipe and then should block but it never blocks int pipe_fd; int res; int open_mode = O_RDONLY; char buf[100]; int bytes_read = 0; memset (buf, '\0', sizeof(buf)); pipe_fd = open(FIFO_NAME, open_mode); if (access(FIFO_NAME, F_OK) == -1) { res = mkfifo(FIFO_NAME, 0777); if (res != 0) { fprintf (stderr, "Could not create fifo %s\n", FIFO_NAME); exit (EXIT_FAILURE); } } for(;;) { do { res = read(pipe_fd, buf, sizeof(buf)); bytes_read += res;

Is there a way to improve performance of linux pipes?

跟風遠走 提交于 2020-01-01 04:43:37
问题 I'm trying to pipe extremely high speed data from one application to another using 64-bit CentOS6. I have done the following benchmarks using dd to discover that the pipes are holding me back and not the algorithm in my program. My goal is to achieve somewhere around 1.5 GB/s. First, without pipes: dd if=/dev/zero of=/dev/null bs=8M count=1000 1000+0 records in 1000+0 records out 8388608000 bytes (8.4 GB) copied, 0.41925 s, 20.0 GB/s Next, a pipe between two dd processes: dd if=/dev/zero bs

WCF vs. .Net Remoting

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-31 08:12:10
问题 according to this article, WCF with named pipes is the best choice for IPC, and it is around 25 % faster than .Net Remoting. I have the following code that compares WCF with named pipes with .Net Remoting: [ServiceContract] internal interface IRemote { [OperationContract] string Hello(string name); } [ServiceBehavior] internal class Remote : MarshalByRefObject, IRemote { public string Hello(string name) { return string.Format("Hello, {0}!", name); } } class Program { private const int

How to do a non-waiting write on a named pipe (c#)?

痴心易碎 提交于 2019-12-31 07:20:08
问题 I'm using .net 3.5 named pipes and my server side is : serverPipeStream = new NamedPipeServerStream("myPipe", PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous); When I write some data with, say, BinaryWriter, the write() call itself doesn't return until the client side has called a read() on its NamedPipeClientStream. The BinaryWriter is : writer = new BinaryWriter(serverPipeStream); I'm aware that NamedPipeServerStream offers a BeginRead/BeginWrite but from what I

Best way to keep a pipe open after a remote close

匆匆过客 提交于 2019-12-31 03:12:11
问题 Using this tutorial i came up with the code below. My client is ran frequently. Its activated via clicks and possibly can be launched twice at the same moment in certain circumstance. I am worried one client may close while another client opens which causes the pipe to be closed in that slim few milliseconds. Whats the best way to keep the pipe open? static public void ThreadStartServer() { while (true) { using (NamedPipeServerStream pipeStream = new NamedPipeServerStream("mytestpipe")) {

Inter-Process communication options

别说谁变了你拦得住时间么 提交于 2019-12-30 18:30:49
问题 I need to subscribe inside one app for the event exposed by another app. I noticed that many people consider the using of WCF Named Pipes as the best practice. Am I right that if I choose WCF Named Pipes I'll have to use IIS? And by the way, what options do I have in general? 回答1: Named pipes are one of the fastest way to do IPC (inter-process communication) on the same machine. The have existed for a long while (was NT4 the first OS?) and not specific for WCF. I would however not use WCF

C++ Windows Asynch IO Named Pipe first message not received

*爱你&永不变心* 提交于 2019-12-30 13:29:11
问题 Modified code from Named Pipe Server Using Overlapped I/O https://msdn.microsoft.com/en-us/library/windows/desktop/aa365603(v=vs.85).aspx The server code is as follows: #include <windows.h> #include <stdio.h> #include <tchar.h> #include <strsafe.h> #include <iostream> #define CONNECTING_STATE 0 #define READING_STATE 1 #define INSTANCES 4 #define PIPE_TIMEOUT 5000 #define BUFSIZE 4096 typedef struct { OVERLAPPED oOverlap; HANDLE hPipeInst; TCHAR chRequest[BUFSIZE]; DWORD cbRead; TCHAR chReply

Setting named pipe security in a Domain

房东的猫 提交于 2019-12-30 12:21:39
问题 I have a server that I'm setting up over a named pipe. It works fine for administrators of the domain, but when I test the client on a normal user, it gives the exception "Access to path is denied". So here is what I'm trying to set the permissions to give access to all authenticated users in the domain. What am I doing wrong here? Server: NamedPipeServerStream pipeServer = new NamedPipeServerStream("message-generator", PipeDirection.InOut, pipeThreads, PipeTransmissionMode.Message,

Can't use named pipe from C to communicate with shell script

£可爱£侵袭症+ 提交于 2019-12-30 12:10:38
问题 I have a C program like so (copied from here): #include <fcntl.h> #define PATH "testpipe" #define MESSAGE "We are not alone" int main() { int fd; mkfifo ( PATH, 0666 ); fd = open ( PATH, O_WRONLY ); write ( fd, MESSAGE, sizeof ( MESSAGE ) ); close ( fd ); unlink ( PATH ); return 0; } and a shell script like so: echo < testpipe Once I execute the C program, the echo statement returns, but We are not alone is not printed. I have also tried creating the pipe from the command line, and with mknod

How to continue sending/reading messages from named pipes / streams

烈酒焚心 提交于 2019-12-30 10:25:40
问题 I'm teaching myself to use pipes and I have two apps, one with the PipeServer class and one with the PipeClient class (shown below). The server app creates an instance of the PipeServer and has a text box that calls the WriteMessage method when the text box changes. The client app creates an instance of the PipeClient, sets the MessageReadEvent to a method that fills in a textbox with the given message, and then calls the ReadMessages method. The first time the ReadMessages method is called