Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Only one client can connect to named pipe

I am currently learning about named pipes in Windows using ASP.NET 3.5 and C#. I wrote a small server program which creates a named pipe:

using (NamedPipeServerStream pipeStream = new NamedPipeServerStream(pipeName))
{
  pipeStream.WaitForConnection();
  // do sth.
}

and a client application opening the pipe like this:

using (NamedPipeClientStream pipeStream = new NamedPipeClientStream(pipeName))
{ 
  pipeStream.Connect();
  // do sth.
}

This works great as long as only one client connects to the pipe. It can both read and write. If I try to connect a second client, the code never exceeds the line

pipeStream.Connect();

Both the server and all clients are running on the same machine. Any ideas?

Thank you very much in advance!

like image 709
Shackles Avatar asked Oct 12 '09 18:10

Shackles


1 Answers

you can look up some of the info here: Number of Clients that can connect to a Named Pipe

and here in MSDN: http://msdn.microsoft.com/en-us/library/aa365594%28VS.85%29.aspx

from what i understand, you should create a multi-threaded application. main thread should be responsible for the future connections, and each new connection should be launched in new thread.

like image 126
0100110010101 Avatar answered Sep 28 '22 16:09

0100110010101