C++ in Windows: GetLastError code 998 during named pipe communication
I have implemented a named pipe server that communicates with multiple named pipe clients. Generally it works, but in some instances, the Client would not be able to get a valid result from TransactNamedPipe. The GetLastError code returned is 998 (Invalid memory access). Which is weird, because the handle I used for TransactNamedPipe was valid from CreateFile.
I have implemented the client to retry when it detects an error (unless the pipe server is not alive). For other error codes (997, 230, 231) it works fine. But when it encounters error code 998, no matter how many times it retries, the named pipe server does not respond; in the named pipe server logs, it just says that the client disconnected, but there was no data exchange.
What could be the reason behind this? Is it because the client requests are coming from multiple threads and the named pipe server cannot cope with the (almost) simultaneous requests? I also implemented "locks" to prevent simultaneous requests from the client to the named pipe server, but the error still occurs.
I have searched the web for named pipe communication with this similar p开发者_StackOverflow社区roblem, but so far, no results.
Thanks in advance
This is weird, indeed. I updated to the latest Windows SDK, pointed my project to it, and, without any changes to the code, it now works perfectly. It must have been a bug that's already been fixed. I was using the libs that came with VC++ 9.0.
精彩评论