c# - Catch the exception thrown at client side when the server closed the pipe -


i checked similar questions question seems simpler , straightforward: there server , client , named pipe between.

the client listens messages server sends (while loop).

how detect server closed pipe, softly close client well?

i saw 3 options:

  1. put pipehhandle.isclosed in while condition of listening client loop
  2. catch objectdisposedexception hoping catch end of communication , not other failures (this exception not give exception errorcode).
  3. catch system.componentmodel.win32exception , check inside exception errorcode (-2147467259). standard put "if" in catch code?

i did not find specific exception "ended pipe" although program (without catch) throw exception number 109 or -2147467259, confused.

thanks help.

the common way know other side dead "echo": once in while(let's every 10 seconds) client sends "echo" - meaning simple request server replay. if 3 echo in row(could more, depend on you) did not answered server, client decide server down , disconnect side


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -