Named Pipes Matlab

我怕爱的太早我们不能终老 提交于 2021-02-11 01:44:31

问题


I am having trouble locating an example for creating a windows named pipe in matlab.

Any suggestions on how to program or where to look?


回答1:


Using .NET's System.IO.Pipes is probably the easiest way out of the box, easier than writing a MEX file to call the Win32 API. Matlab lets you call .NET directly from M-code, and the objects are managed so resource cleanup will be easier. .NET 3.5 and newer support named pipes.

The resulting M-code would look something like this. (Sorry; I don't have Matlab at the moment so can't test it.)

NET.addAssembly('System.Core'); %# might be superfluous
pipeStream = System.IO.Pipes.NamedPipeServerStream('testpipe', System.IO.Pipes.PipeDirection.Out);

Nowadays, I think .NET is the easiest way to access native Windows features that Matlab doesn't directly expose. So for something like this, the first thing to try is looking for examples of doing it in C#. If it can be done in C# using .NET standard library features, you can often translate it pretty directly to M-code. E.g. I found this one by Googling for "create named pipe .net" and getting this example. Loren discusses this technique here.



来源:https://stackoverflow.com/questions/12649778/named-pipes-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!