开发者

GetLastError returning ERROR_SUCCESS after calling ConnectNamedPipe

开发者 https://www.devze.com 2022-12-20 10:50 出处:网络
When I call Conne开发者_开发百科ctNamedPipe with an OVERLAPPED structure and check GetLastError afterwards, I often see GetLastError return ERROR_SUCCESS. The way I\'m reading the documentation, that

When I call Conne开发者_开发百科ctNamedPipe with an OVERLAPPED structure and check GetLastError afterwards, I often see GetLastError return ERROR_SUCCESS. The way I'm reading the documentation, that should never happen. My understanding is that if a client has already connected, ERROR_PIPE_CONNECTED should be set, not ERROR_SUCCESS.

Has anyone else seen this? The OS is 32-bit Windows 7.


That's typical for OVERLAPPED. It tells whether the parameters are okay before connecting, assuming an asynchronous socket. Once a connection completes or fails, then GetOverlappedResult() returns the proper status. So I guess this is a minor documentation error.


Try calling GetLastError() immediately after ConnectNamedPipe. Don't call any API in between.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号