I have two applications talking to each other via NamedPipes
. Let's call them appServer
(server) and appClient
(client). They successfully connect and send data back and forth for some length of time. Then, unexpectedly, appClient
crashes. The user relaunches it and tried to connect to the pipe but appServer
still thinks that it is connected and so isn't listening for a new connection.
I am currently using a NamedPipeServerStream
on the server side (which returns .IsConnected
as true
, and NamedPipeClientStream
on the client side (which returns .IsConnected
as false
).
My question is this: can I somehow get the client side to be able to reconnect? I've obviously tried .Connect
with or without a timeout but no luck.
Any tips are appreciated! Thanks!
EDIT: Another valid (albeit undesirable) option would be performing some cheap operation on the server side to basically do a 'connection test' to make sure the client is 'still there'. Anyone know one of these? Besides sending a dummy message I'm not sure the best way of doing this. I don't like this option as it would have to happen continuously but I'm open to all avenues right meow.
Our solution ended up being to initiate a second thread that waited for another connection. We then compared the client and if it was the same client then we closed and recycled the original server pipe to keep it clean.