What is the reason for opening a named pipe only once per machine? .I mean what is the reas开发者_Go百科on behind this restriction?
I haven't tested this but it makes sense that only one listener can be open on a single named pipe. Allowing two instances of the pipe to be open would create a range of issues, to start with:
- When we send a message to the service, how do we know which listener is going to accept our message?
- Do we really need the overhead of avoiding race conditions when two listeners are trying to receive the same message?
- Would we expect each listener to receive the message, or just one?
Keep in mind that allowing two listeners on the same named pipe would allow two completely different services to receive the same messages. There is simply no reason to allow this to happen.
Update
Chris Dickson points out that allowing two listeners on the same pipe creates a security issue known as a squatting attack, where a fraudulent host can receive requests and steal the identity of the caller. This is a ramification of point 1 above.
精彩评论