Jump to content


Named Pipes in C++


2 replies to this topic

#1 code2K

    New Member

  • Members
  • PipPip
  • 10 posts

Posted 17 October 2006 - 09:21 PM

Hi, I need to close the server end of a Named Pipe gracefully when the server is waiting on ReadFile() in blocking mode. Have tried just doing a disconnect() and CloseHandle() but the pipe just stays open requiring a reboot to free it. Would be grateful for any advice.

#2 donBerto

    Senior Member

  • Members
  • PipPipPipPip
  • 369 posts

Posted 17 October 2006 - 10:06 PM

In a blocking context, I'm not sure you can gracefully terminate a named pipe, other than sending the pipe a message which it can then use to shut itself down.

Alternatively, you can use a named pipe in a non-blocking manner and use polling to determine events. In the case where the named pipe is no longer needed, you can simply shut it down with no 'hang up' as it is non-blocking.

hope that helps.
Imagine.

#3 code2K

    New Member

  • Members
  • PipPip
  • 10 posts

Posted 18 October 2006 - 04:27 AM

Thanks for the reply. Thats given me food for thought. I was hoping I might be able to shut it down while its waiting on a ReadFile() but perhaps not. I have to use the pipe in blocking mode and so this a tricky problem. Perhaps I can use WaitForMultipleObjects() and have the pipe and an event object waited-on and use the event object as the trigger to close the pipe?? Gonna try. Will update if succesful..





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users