0

I have an application in which we can open multiple instances. For some real time communication between the instances I want to use named pipes.

The communication will not be frequent but whenever it is done it needs to be almost realtime. So I am contemplating whether I should open a named pipe whenever a need to transmit such messages arises OR keep the pipe open from the start of application and use it whenever needed.

Is keeping named pipes open for entire duration ok?

Doctor Jones
  • 21,196
  • 13
  • 77
  • 99
puneet
  • 769
  • 1
  • 9
  • 34
  • I'm guessing it's along the lines of a connection to a Database, why keep it around if you need it? P.S this more a software architecture/ best practice question. I recommend posting these on https://softwareengineering.meta.stackexchange.com – MindSwipe Dec 04 '18 at 14:25
  • Keeping a named pip open shouldn't be an issue. How do you know which instance is the client and which is the server? – jdweng Dec 04 '18 at 14:25
  • Short answer: yes, since pipes aren't going to be more expensive than processes. Longer answer: use WCF with the named pipes transport and don't reinvent the wheel. – Jeroen Mostert Dec 04 '18 at 14:26
  • Use WCF, you could later change it to another type of communication if needed without much work. https://stackoverflow.com/questions/7353670/wcf-named-pipe-minimal-example – Cleptus Dec 04 '18 at 14:39
  • So in essence in wcf we create the server at the start of application, so it would be fine for me also to keep pipes open – puneet Dec 04 '18 at 14:45
  • Pipes are not for free, there is kernel memory pool associated with it, depending on the pipe buffer size. Knowing when it is good time to open the pipe again has to be the harder problem, that requires some other kind of synchronization primitive. Like a pipe :) – Hans Passant Dec 04 '18 at 15:05

0 Answers0