pipestream | handle pipe stream | Stream Processing library
kandi X-RAY | pipestream Summary
kandi X-RAY | pipestream Summary
handle pipe stream
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of pipestream
pipestream Key Features
pipestream Examples and Code Snippets
Community Discussions
Trending Discussions on pipestream
QUESTION
Apologies if this question is overly broad. I'm new to C++ and trying to understand different stream types and why they matter (or doesn't matter).
I'm learning by coding a simple program that launch a child process, and process the output. I'm following the Boost process synchronous IO example: https://www.boost.org/doc/libs/1_75_0/doc/html/boost_process/tutorial.html#boost_process.tutorial.io.
One of the example can be reduce to this:
...ANSWER
Answered 2021-Feb-07 at 23:02Programs interact with their environment in various ways. One set of channels are the standard input, output and error streams.
These are often tied to a terminal or files by a shell (cmd.exe, sh, bash etc).
Now if programs interact with eachother, like:
QUESTION
I am trying to achieve IPC with two WPF Application running on the same machine.I need to achieve something similar to Example using Winform. Can some one convert the below code to WPF/C# as you can see the delegate invoke is directly dependent on Winform Control,
...ANSWER
Answered 2020-Aug-05 at 13:28Replace Invoke
with Dispatcher.Invoke
, e.g.:
QUESTION
I'm trying to use PipeSecurity
to secure a NamedPipeServerStream
. When I call this.pipeServer.SetAccessControl(pipeSecurity)
in the snippet below I get the following exception:
ANSWER
Answered 2019-Feb-27 at 09:23I just had the same issue and tried to track it down.
TL;DRThe current status (Feb-2019) is sad but true: it just does not work with the classes that are given in today's NET Standard.
Ticket references- issue 30170 “unauthorized operation” on NamedPipeServerStream.SetAccessControl
- issue 31190 System.IO.Pipes.AccessControl package does not work
- issue 24040 NamedPipeServerStream: Provide support for WRITE_DAC
Also interesting in this context could be the *nix-related
Possible workaroundOne still can use native API calls to get security set up as desired, but that's not for the faint of heart. One basically needs to implement these steps:
- set up a security descriptor in binary representation
- connect it to the
SECURITY_ATTRIBUTES
structure - create the pipe via Windows API
CreateNamedPipe()
- wrap the resulting handle into a
SafeHandle
- and feed that into the right NamedPipeServerStream CTOR variant
PS: At least we now can look it up in the code where it is hitting the wall. Just imagine having that problem 20 years ago ...
QUESTION
Here is the following code :
...ANSWER
Answered 2019-Feb-26 at 18:26If losing the database connection is rare, letting the server crash, and some supervisory process restart it, works quite well.
If losing the DB connection is common enough that you can't tolerate client timeouts from restarting the server, you can add reconnect logic to whatever code uses the DB connection. I usually use resource-pool for this. I believe you can create the "pool" with only one resource, if that fits your database.
Usually getting a DB connection is fast, so I'm guessing it's not worth extra effort to route incoming requests elsewhere. withResource
in resource-pool
blocks until a resource is ready, so active requests can easily wait while you reconnect.
QUESTION
I have a C# client application that connects to a C++ server application using Pipes. When I try to connect I get the error: System.UnauthorizedAccessException: Access to the path is denied.
After looking this up, I saw that I can fix it by creating a PipeSecurity object and adding a PipeAccessRule. But this only works if the server is also a C# application.
Any idea how I can fix this access problem if I have the server as C++ application?
I searched already but can't find a solution.
C#:
...ANSWER
Answered 2018-Jan-09 at 19:11The last parameter of the [CreateNamedPipe function] specifies:
lpSecurityAttributes [in, optional]
A pointer to a SECURITY_ATTRIBUTES structure that specifies a security descriptor for the new named pipe and determines whether child processes can inherit the returned handle. If lpSecurityAttributes is NULL, the named pipe gets a default security descriptor and the handle cannot be inherited. The ACLs in the default security descriptor for a named pipe grant full control to the LocalSystem account, administrators, and the creator owner. They also grant read access to members of the Everyone group and the anonymous account.
The C++ named pipe server application has Administrator privilege since it is running as a Windows service under the LocalSystem account. The C# client application running as a Standard user does not have Administrator privilege. By default (lpSecurityAttributes
is NULL
), the C# client application has only read access to the named pipe created by the C++ server running as a service.
As a quick test, if you run the C# client application as Administrator, it should be able to communicate with the C++ server application successfully.
To fix the problem, the C++ server application needs to create a security descriptor for the named pipe object and grant write access to it for Everyone. Please see MSDN example for creating a security descriptor.
I wrote a class NamedPipeServerStream
before for my C++ server application running as a service. Here is the part of the code related to creating the named pipe for your reference.
QUESTION
I'm trying to get a C++ application to let a C# application know when a particular action happens. The way I'm trying to do this is via named pipes.
I've set up a named pipe server on the C++ app, which seems to be working (the named pipe gets created - it appears on the list retrieved by PipeList) and a named pipe client on the C# app, where it fails: First line of the C# client code gives "Pipe handle has not been set. Did your PipeStream implementation call InitializeHandle?" error, and line 2 throws "Access to the path is denied" exception.
Where am I going wrong?
C++ Server Code
...ANSWER
Answered 2017-May-02 at 16:20The named pipe creation doesn't have the right parameters.
First you want to read & write on the pipe, so the flag to use is : PIPE_ACCESS_DUPLEX
Then, here you are sending messages in synchronous mode. Use these flags : PIPE_WAIT | PIPE_TYPE_MESSAGE
Finally, you are allowing only one instance of this pipe on the machine. Obviously you need at least 2: One for the server one for the client. I would just use the unlimited flag: PIPE_UNLIMITED_INSTANCES
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pipestream
pipeStream.pipe一定要在最后调用,因为执行完pipeStream.pipe,再执行 prepend, addHead, add, addTail, append 对当前的stream串不起作用。 var PipeStream = require('pipestream'); var Transform = require('stream').Transform; /**测试prepend, addHead, add, addTail, append方法**/ var pipeStream = new PipeStream(); //1. //pipeStream.wrapStream(process.stdin); //PipeStream.wrap(process.stdin); pipeStream.wrapStream(process.stdout, true); //PipeStream.wrap(process.stdout, true); //2. //process.stdin.pipe(pipeStream); //3. //pipeStream.dest(process.stdout); var prepend = new Transform(); prepend._transform = function(chunk, encoding, cb) { console.log('---------prepend-------'); cb(null, chunk); }; var addHead = new Transform(); addHead._transform = function(chunk, encoding, cb) { console.log('---------addHead-------'); cb(null, chunk); }; var add = new Transform(); add._transform = function(chunk, encoding, cb) { console.log('---------add-------'); cb(null, chunk); }; var addTail = new Transform(); addTail._transform = function(chunk, encoding, cb) { console.log('---------addTail-------'); cb(null, chunk); }; var append = new Transform(); append._transform = function(chunk, encoding, cb) { console.log('---------append-------'); cb(null, chunk); }; pipeStream.add(add/*, pipeOpts*/); pipeStream.addTail(addTail/*, pipeOpts*/); pipeStream.addHead(addHead/*, pipeOpts*/); pipeStream.prepend(prepend/*, pipeOpts*/); pipeStream.append(append/*, pipeOpts*/); //动态往stream串前面插入stream对象,放在头部最后一个 pipeStream.addHead(function(src, next) { var dest = new Transform(); dest._transform = function(chunk, encoding, cb) { console.log('---------async addHead-------'); cb(null, chunk); }; setTimeout(function() { next(src.pipe(dest)); }, 1000); }); //动态往stream串插入stream对象 pipeStream.add(function(src, next) { var dest = new Transform(); dest._transform = function(chunk, encoding, cb) { console.log('---------async add-------'); cb(null, chunk); }; setTimeout(function() { next(src.pipe(dest)); }, 2000); }); //动态往stream串尾部插入stream对象,放在尾部第一个 pipeStream.addTail(function(src, next) { var dest = new Transform(); dest._transform = function(chunk, encoding, cb) { console.log('---------async addTail-------'); cb(null, chunk); }; setTimeout(function() { next(src.pipe(dest)); }, 3000); }); //动态往stream串尾部插入stream对象,放在尾部最后一个 pipeStream.append(function(src, next) { var dest = new Transform(); dest._transform = function(chunk, encoding, cb) { console.log('---------async append-------'); cb(null, chunk); }; setTimeout(function() { next(src.pipe(dest)); }, 4000); }); //动态往stream串前面插入stream对象,放在头部第一个 pipeStream.prepend(function(src, next) { var dest = new Transform(); dest._transform = function(chunk, encoding, cb) { console.log('---------async prepend-------'); cb(null, chunk); }; setTimeout(function() { next(src.pipe(dest)); }, 5000); }); //1. //process.stdin.pipe(process.stdout); process.stdout.src(process.stdin); //2. //pipeStream.pipe(process.stdout); //3. //pipeStream.src(process.stdin); //process.stdin.pipe(pipeStream).pipe(process.stdout);
PipeStream(options) 跟正常的stream的options参数唯一区别是PipeStream多了一个pipeError的属性,用来标示是否整个pipeStream里面的stream串出现异常时把异常都传递给pipeStream.pipe(dest)里面的dest对象处理。
pipeStreamObj.prepend(dest, pipeOpts) 把dest放到stream串头部第一个位置,dest可以为一个回调方法,pipeStream会自动执行该回调方法,其上一个stream及执行下一步的回调,具体使用见Example
pipeStreamObj.addHead(dest, pipeOpts) 把dest放到stream串头部最后一个位置,dest同prepend方法
pipeStreamObj.add(dest, pipeOpts)、 pipeStreamObj.insert(dest, pipeOpts, index) 把dest放到stream串中间最后一个位置,dest同prepend方法
pipeStreamObj.addTail(dest, pipeOpts) 把dest放到stream串尾部第一个位置,dest同prepend方法
pipeStreamObj.append(dest, pipeOpts) 把dest放到stream串尾部最后一个位置,dest同prepend方法
pipeStreamObj.pipe(dest, pipeOpts) 同stream.pipe,执行这个方法后stream串将创建完毕,无法再往该stream串插入stream对象。
pipeStreamObj.dest(dest, pipeOpts) 相当于pipeStreamObj.pipe,这个要与pipeStreamObj.src一起使用,用于从dest-->src的顺序pipe stream
pipeStreamObj.src(src, pipeOpts) 相当于src.pipe(pipeStreamObj, pipeOpts),执行该方法后,不能再调用prepend、append、add、addHead、addTail方法
pipe(pipeStreamObj, pipeOpts)`,这个与pipeStreamObj.dest一起使用,执行这个方法后stream串将创建完毕,无法再往该stream串插入stream对象。。
PipeStream.Transform pipeStreamObj.add(new PipeStream.Transform())相当于pipeStreamObj.add(new require('stream').PassThrough({objectMode: 1}), {end: false}),且在执行PipeStream.Transform.prototype._transform(chunk, encoding, cb)方法时,如果传过来的chunk为null,则表示这是最后一个回调,执行该回调后流将结束,无需再监听end事件。
pipeStreamObj.wrapStream(stream, dest, pipeOpts) PipeStream.wrap(stream, dest, options) 把stream转成pipeStream,dest表示为用于被pipe的stream,看示例。
PipeStream.pipe(stream, pipeOpts) 默认设置{end: false},且会加入ending事件。
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page