By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,703 Members | 1,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,703 IT Pros & Developers. It's quick & easy.

Use of Named Pipes in .Net

P: n/a
Is there any built-in facility for handling named pipes in C#/.Net, or must
one use unsafe code to access the WIN32 API directly?

There exists some code that uses named pipes heavily and there exists a need
for that code to send some information to a new .Net service I am writing.
It is a relatively simple matter for the existing code to use a named pipe
to send the data, but I can find no references to how I can create the named
pipe and manage it from the .Net side.

-Ken
Nov 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Ken,
Is there any built-in facility for handling named pipes in C#/.Net,


No

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2

P: n/a

"Ken Allen" <ke******@sympatico.ca> wrote in message
news:eI**************@TK2MSFTNGP09.phx.gbl...
Is there any built-in facility for handling named pipes in C#/.Net, or must one use unsafe code to access the WIN32 API directly?

There exists some code that uses named pipes heavily and there exists a need for that code to send some information to a new .Net service I am writing.
It is a relatively simple matter for the existing code to use a named pipe
to send the data, but I can find no references to how I can create the named pipe and manage it from the .Net side.


You must use Win32 to create or open the named pipe, but once you have a
handle to the named pipe, you can just wrap it in a System.IO.FileStream to
read and write.

To replicate the example here
http://msdn.microsoft.com/library/de...ipe_server.asp

for a mutithreaded pipe server, it looks like you'll need to call

CreateNamedPipe
ConnectNamedPipe
DisconnectNamedPipe
CloseHandle

through P/Invoke.

The FileStream will take care of ReadFile, WriteFile, FlushFileBuffers and
CloseHandle on the connected pipe instance.

David
Nov 16 '05 #3

P: n/a
Unfortunate. I did read the other response concerning using the CreateFile()
API call first, but...

Am I correct in my believe that a simple TCP/IP socket should be no problem
for this type of solution? The existing C++ (not .Net) service could send
the data buffer over the TCP/IP socket and the .Net service could create and
receive over the socket?

-Ken

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:O2**************@TK2MSFTNGP09.phx.gbl...
Ken,
Is there any built-in facility for handling named pipes in C#/.Net,


No

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 16 '05 #4

P: n/a
"Ken Allen" <ke******@sympatico.ca> wrote:
Is there any built-in facility for handling named pipes in C#/.Net, or must
one use unsafe code to access the WIN32 API directly?

There exists some code that uses named pipes heavily and there exists a need
for that code to send some information to a new .Net service I am writing.
It is a relatively simple matter for the existing code to use a named pipe
to send the data, but I can find no references to how I can create the named
pipe and manage it from the .Net side.

-Ken


Item 13.13 Using Named Pipes to Communicate
http://cookbooks.oreilly.com/

Source Code is here
http://examples.oreilly.com/csharpckbk/
Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.