named-pipes

using istream to read from named pipe

大憨熊 提交于 2019-12-22 10:28:57
问题 Is it possible to read from named pipe (mkfifo) using c++ (stl) using a stream - thus not defining in advance char *buffer[MAX_SIZE] for the read operation? I want to read till the buffer ends and put the result into std::string . (Current method: bytes = read(fd, buffer, sizeof(buffer)); requires allocation some kind of buffer in advance.) 回答1: Named pipes created with mkfifo behave like regular files. Thus they can be accessed using std::ifstream and std::ofstream : #include <fstream>

PeekNamedPipe always returns 0 for totalBytesAvailable

老子叫甜甜 提交于 2019-12-22 09:01:11
问题 PeekNamedPipe( tmp_pipe, // __in HANDLE hNamedPipe, NULL, // __out_opt LPVOID lpBuffer, 0, // __in DWORD nBufferSize, NULL, // __out_opt LPDWORD lpBytesRead, &totalBytesAvailable, // __out_opt LPDWORD lpTotalBytesAvail, NULL // __out_opt LPDWORD lpBytesLeftThisMessage ); I have written bytes to the pipe somewhere else,but totalBytesAvailable is always 0 ,why? 回答1: I have found that in Windows, if you call PeekNamedPipe before calling ReadFile , it will always return zero bytes, even if there

PeekNamedPipe always returns 0 for totalBytesAvailable

試著忘記壹切 提交于 2019-12-22 09:00:02
问题 PeekNamedPipe( tmp_pipe, // __in HANDLE hNamedPipe, NULL, // __out_opt LPVOID lpBuffer, 0, // __in DWORD nBufferSize, NULL, // __out_opt LPDWORD lpBytesRead, &totalBytesAvailable, // __out_opt LPDWORD lpTotalBytesAvail, NULL // __out_opt LPDWORD lpBytesLeftThisMessage ); I have written bytes to the pipe somewhere else,but totalBytesAvailable is always 0 ,why? 回答1: I have found that in Windows, if you call PeekNamedPipe before calling ReadFile , it will always return zero bytes, even if there

Windows 8 named pipe creation

别来无恙 提交于 2019-12-22 06:57:45
问题 How I can create named pipe in the Windows 8 with AppContainer integrity level? 回答1: As Pavel Minaev mentioned in one of comments to some answer, there are no named pipes in WinRT (for Metro applications, for desktop applications pipes are the same as in Windows 7): Named pipes aren't there, for example, nor are memory mapped files. There are sockets (including server sockets), but when connecting to localhost, you can only connect to the same app. You may be interested in the WinRT API,

Synchronizing reading and writing with synchronous NamedPipes

我与影子孤独终老i 提交于 2019-12-21 23:22:49
问题 A Named Pipe Server is created with hPipe = CreateNamedPipe( zPipePath, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT | PIPE_READMODE_BYTE, PIPE_UNLIMITED_INSTANCES, 8192, 8192, NMPWAIT_USE_DEFAULT_WAIT, NULL) Then we immediately call: ConnectNamedPipe( hPipe, BYVAL %NULL ) Which blocks until the client connects. Then we proceed directly to ReadFile( hPipe, ... The problem is that it takes the Client takes a finite amount of time to prepare and write all the fcgi request parameters. This has

return value from child process c

廉价感情. 提交于 2019-12-21 18:41:36
问题 I need help returning a "status code" from my child program back to the parent, where it will check the status code, print code, and exit the parent. This is for a class project, so I will put some relevant code here, but I don't to post the entire project for obvious reasons. I have forked and created the child process through exec. The parent does some fancy math and uses a named pipe to push data to the child process. The child does some more fancy math. When I uses a keyword, the child

return value from child process c

谁说我不能喝 提交于 2019-12-21 18:41:34
问题 I need help returning a "status code" from my child program back to the parent, where it will check the status code, print code, and exit the parent. This is for a class project, so I will put some relevant code here, but I don't to post the entire project for obvious reasons. I have forked and created the child process through exec. The parent does some fancy math and uses a named pipe to push data to the child process. The child does some more fancy math. When I uses a keyword, the child

Named Pipes server, how to interrupt or timeout the wait for client connection and for incoming data

房东的猫 提交于 2019-12-21 17:46:01
问题 I am writing a simple Named Pipes server for Windows, calling the Windows API (in Java with JNA but this is not relevant). I am trying to figure out how to avoid that the server stays stuck forever waiting for a client to connect or for data to come from the client. The server code does the following: 1) It creates the pipe by calling CreateNamedPipe, with PIPE_WAIT in the dwPipeMode argument. 2) It calls ConnectNamedPipe which doesn't return until a client has connected. 3) It enters a loop

What is an overlapped I/O alternative to WaitNamedPipe?

南笙酒味 提交于 2019-12-21 13:16:09
问题 The WaitNamedPipe function allows a pipe client application to synchronously wait for an available connection on a named pipe server. You then call CreateFile to open the pipe as a client. Pseudocode: // loop works around race condition with WaitNamedPipe and CreateFile HANDLE hPipe; while (true) { if (WaitNamedPipe says connection is ready) { hPipe = CreateFile(...); if (hPipe ok or last error is NOT pipe busy) { break; // hPipe is valid or last error is set } } else { break; //

C# all pipe instances are busy

陌路散爱 提交于 2019-12-21 09:34:36
问题 The following code creates a new thread acting first as a named pipe client for sending parameters and then as a server for retrieving results. After that it executes a function in another AppDomain acting as a named pipe server and after that as a client to send the results back. public OrderPrice DoAction() { Task<OrderPrice> t = Task<OrderPrice>.Factory.StartNew(NamedPipeClient, parameters); if (domain == null) { domain = AppDomain.CreateDomain(DOMAINNAME); } domain.DoCallBack