Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Number of Clients that can connect to a Named Pipe

Tags:

c#

named-pipes

Say a server created a named pipe "myTestPipe". How many clients can connect to "myTestPipe"? From what I have read on the Web, it seems only one client can, but wanted to make sure.

If only one, then it's best to use the blocking WaitForConnection() instead of the Asunchronous method BeginWaitForConnection() as the server will wait until a client process connects and then do the communication?! (no need to worry about other clients to connect)

like image 635
Derar Avatar asked Aug 12 '09 15:08

Derar


People also ask

What is a named pipe connection?

Named pipes are application programming interfaces (APIs) for bidirectional interprocess communication (IPC) on Windows. Named-pipe connections provide a high-level interface to network software by making transport-layer operations transparent.

Can multiple processes write to the same named pipe?

Yes, multiple processes can read from (or write to) a pipe. But data isn't duplicated for the processes.

Are named pipes full duplex?

A named pipe is a named, one-way or duplex pipe for communication between the pipe server and one or more pipe clients. All instances of a named pipe share the same pipe name, but each instance has its own buffers and handles, and provides a separate conduit for client/server communication.

Are named pipes connection oriented?

Connection-oriented transports such as named pipes and TCP are ideal for crossing process and machine boundaries, and yield greater performance and reliability than HTTP transport. Named pipes support reliable and sequential data transfer (FIFO) via memory-mapped files.


2 Answers

You can have more than one client connect to the same named pipe. On Windows, I believe the current limitation is 256 simultaneous connections to a single named pipe, including the server's connection.

(Unfortunately, I can't track down the appropriate MSDN page for reference, but this CPAN pipes reference mentions this limitation.)

like image 166
Reed Copsey Avatar answered Sep 27 '22 00:09

Reed Copsey


You actually create one pipe and wait for a connection, and when it connects, create a second one and wait on it.

For each pipe you create and wait for connection on, you get at most one connection (at a time - you can recycle them if they are request/response/close style).

Thus, each connection is 1-to-1, like a socket or other stream.

like image 35
Joshua Muskovitz Avatar answered Sep 23 '22 00:09

Joshua Muskovitz