How to read from a named pipe in 'Message' mode [Windows]?

16 views (last 30 days)
I am trying to read from a named pipe in Windows using the .NET framework. I am using the following code to connect to the pipe:
NET.addAssembly(System.Core)
pipeClient = System.IO.Pipes.NamedPipeClientStream('.','pipeName',System.IO.Pipes.PipeDirection.In);
pipeClient.Connect();
Once the pipe is connected, the pipeClient TransmissionMode and ReadMode are set to 'Byte,' but I want to read from the pipe in 'Message' mode. When I try to change the ReadMode, I get the following error:
>> pipeClient.ReadMode = System.IO.Pipes.PipeTransmissionMode.Message
Message: Access to path is denied.
Source: System.Core
HelpLink:
If anyone can help me, I'd greatly appreciate it!!
NOTE: I am not an object oriented programmer, so please be kind :-)...
  1 Comment
Dasharath Gulvady
Dasharath Gulvady on 28 May 2015
Are you able to achieve this outside MATLAB? If yes, how are you doing this? If not, can you try outside MATLAB and make sure it works in the .NET environment?

Sign in to comment.

Answers (1)

Ayush
Ayush on 2 Dec 2024
The error message you are encountering originates from .NET, specifically from "System.Core." This issue can likely be replicated in C#, allowing you to search for the error online for more information. For instance, searching for "Access to the path is denied. pipes" yields numerous helpful discussions. Access to named pipes, like other Windows resources, is governed by access control privileges, such as Access Control Lists (ACLs). I recommend checking for any references to access control, and if necessary, explicitly configuring these controls to allow access from other processes within your login session.
Regarding alternatives in MATLAB for inter-process data transfer:
Use of Named Pipes typically works well. An alternative is using shared memory, but programming shared memory is more difficult and error prone and my experience is that it is less of a performance boost that you might expect.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!