Question

Hye i am using a named pipe for rpc, when the server gets an exception writing to the pipe ( for example the client side suddenly closed) I catch the exception ,call disconnect named pipe and then i try to call connectNamedPipe ,I get 232: pipe is being closed. My question is how to solve this issue ,so after I get an exception to start listening on the pipe again

Was it helpful?

Solution

Sorry, but don't know if it is too late. This thread seems to be quite old.

But just for the benefits of those who are like me who Google this problem here.

The problem the thread starter faced is simple, THE CLIENT CANNOT RECONNECT TO THE SAME PIPE AFTER IT IS DISCONNECTED!

So in the event that the pipe on the client side is suddenly closed, the pipe on the server side is dead as well. If you want to reconnect, the server needs to provide another CreateNamedPipe function to get the new connection and ask the client to try it.

The key is the understanding of pipes.

OTHER TIPS

I have met the same problem but a bit different from Leon.

In my case, ReadFile() returns 232 "pipe is being closed". The message is miss-leading. The pipe is not being closed. ReadFile() is just returning without any data read.

Since the pipe I created is non-blocking, it makes perfect sense for ReadFile() returns immediately without data.

If you check the error code in winerror.h, that is "ERROR_NO_DATA", which is much better than "pipe is being closed"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top