named-pipes

C++ Linux named pipe hanging on open() with O_WRONLY

两盒软妹~` 提交于 2019-11-30 22:28:37
This is my simple code that opens a named pipe, writes a string to it, and then closes the pipe. The pipe is created in a another function, as mentioned below. char * ipcnm = "./jobqueue"; std::cout << "opening job queue" << std::endl; //ensure the jobqueue is opened if ((jobq = open(ipcnm, O_WRONLY)) < 0) { perror("open"); exit(-1); } std::cout << "queue opened" << std::endl; // record the number of bytes written to the queue size_t written = write(jobq, ptr, size*nmemb); // close fifo if (close(jobq) < 0) { perror("close"); exit(-1); } // need to report to other agents the size of the job

How to respond conditionally based on the request when using netcat

我与影子孤独终老i 提交于 2019-11-30 19:41:35
I am trying to set up a web server using only windows batch scripting. I have already come up with the following script: @echo off @setlocal enabledelayedexpansion for /l %%a in (1,0,2) do ( type tempfile.txt | nc -w 1 -l -p 80 | findstr mystring if !ERRORLEVEL! == 0 ( echo found > tempfile.txt ) else ( echo not-found > tempfile.txt ) ) However, the response is always one request behind, I mean, if I type something like this into the browser: REQUEST: localhost/mystring I will get the following response: RESPONSE: not-found Only in the next request I will receive the correct answer for the

Named Pipes in Go for both Windows and Linux

雨燕双飞 提交于 2019-11-30 19:41:16
I am new to Go, I want to create Named Pipes implementation in Go which works on both Windows and Linux. I managed to get the code working on Ubuntu, but this one does not work on Windows Isn't there any abstraction in Go which allows you to work with Named Pipes in both environment Below is piece of my code //to create pipe: does not work in windows syscall.Mkfifo("tmpPipe", 0666) // to open pipe to write file, err1 := os.OpenFile("tmpPipe", os.O_RDWR, os.ModeNamedPipe) //to open pipe to read file, err := os.OpenFile("tmpPipe", os.O_RDONLY, os.ModeNamedPipe) Any help or pointers would help a

Are there repercussions to having many processes write to a single reader on a named pipe in posix?

佐手、 提交于 2019-11-30 19:12:00
I am writing a program for POSIX (OSX) where I will have many processes sending messages to one listener, who is essentially a logging thread. All of the processes are running in seperate programs, and using a single named pipe (FIFO) that many processes write to, but only a single process reads from is very tempting. Questions: 1) Will this work? - I can make this work using bash to setup a fifo with multiple processes writing to it, so I know in theory this works. But in practice, are there issues I'm glossing over? shell #1 $ mkfifo /tmp/fifo $ cat /tmp/fifo shells #2 and #3 $ cat > /tmp

C++ Linux named pipe hanging on open() with O_WRONLY

爷,独闯天下 提交于 2019-11-30 18:26:43
问题 This is my simple code that opens a named pipe, writes a string to it, and then closes the pipe. The pipe is created in a another function, as mentioned below. char * ipcnm = "./jobqueue"; std::cout << "opening job queue" << std::endl; //ensure the jobqueue is opened if ((jobq = open(ipcnm, O_WRONLY)) < 0) { perror("open"); exit(-1); } std::cout << "queue opened" << std::endl; // record the number of bytes written to the queue size_t written = write(jobq, ptr, size*nmemb); // close fifo if

Client on non-admin user can't communicate using net.pipe with services

丶灬走出姿态 提交于 2019-11-30 16:40:23
I have a client app that hosts a WCF service using net.pipe protocol. The client can't communicate with other WCF services which are running under the admin user. I have read that you can't communicate using net.pipe between different users. Is there way to by pass it? Chris Dickson I have read that you can't communicate using net.pipe between different users. This isn't true in general. Here is a summary of what I think you are referring to: If you are running on an operating system earlier than Windows Vista there is no problem: any process should be able to host a WCF net.pipe service

Named Pipe CreateFile() returns INVALID_HANDLE_VALUE, and GetLastError() returns ERROR_PIPE_BUSY

会有一股神秘感。 提交于 2019-11-30 15:00:59
I have written a class to handle named pipe connections, and if I create an instance, close it, and then try to create another instance the call to CreateFile() returns INVALID_HANDLE_VALUE , and GetLastError() returns ERROR_PIPE_BUSY . What's going on here? What can I do to insure the call to Connect() succeeds? PipeAsync A, B; A.Connect("\\\\.\\pipe\\test",5000); A.Close(); cout << GetLastError(); // some random value B.Connect("\\\\.\\pipe\\test",5000); cout << GetLastError(); // 231 (ERROR_PIPE_BUSY) B.Close(); Here are my implementations of Connect() and Close() BOOL PipeAsync::Connect

WCF Named Pipe IPC

给你一囗甜甜゛ 提交于 2019-11-30 14:18:56
I have been trying to get up to speed on Named Pipes this week. The task I am trying to solve with them is that I have an existing windows service that is acting as a device driver that funnels data from an external device into a database. Now I have to modify this service and add an optional user front end (on the same machine, using a form of IPC) that can monitor the data as it passes between the device and the DB as well as send some commands back to the service. My initial ideas for the IPC were either named pipes or memory mapped files. So far I have been working through the named pipe

How do I read a FIFO/named pipe line by line from a C++/Qt Linux app?

青春壹個敷衍的年華 提交于 2019-11-30 09:42:03
How do I read a FIFO/named pipe line by line from a C++/Qt Linux app? Today I can open and read from a fifo from a Qt program, but I can't get the program to read the data line by line. Qt reads the entire file, meaning he waits until the "sender" closes his session. Let's take a example with some shell commands to show what I would like the app to do. First create a fifo mkfifo MyPipe Then we can use cat to read from the fifo cat MyPipe And then we send some data in with another cat cat > MyPipe And then start to type something, and every time you hit enter it arrives at the reader. And then

C# UnauthorizedAccessException when enabling MessageMode for read-only named pipe (NamedPipeClientStream class)

梦想与她 提交于 2019-11-30 08:42:47
There's a problem with the NamedPipeClientStream class in .NET, in that you cannot create an instance of this class with PipeDirection.In , and then successfully change the ReadMode to PipeTransmissionMode.Message . Attempting to do so will raise an UnauthorizedAccessException . Although pipes would usually be used to communicate between processes, this simple example within a single process shows the problem: var pipeOut = new NamedPipeServerStream("SomeNamedPipe", PipeDirection.Out, 1, PipeTransmissionMode.Message); var pipeIn = new NamedPipeClientStream(".", "SomeNamedPipe", PipeDirection