WTSVirtualChannelRead sometimes drops packets when using timeouts

Michael Lombardi 1 Reputation point

I am using WTSVirtualChannelRead and have noticed some incorrect behavior that occurs when using timeouts. I believe that when a packet is sent from the client just as the function is timing out, GetLastError returns ERROR_IO_INCOMPLETE and pBytesRead is 0 as usual during a timeout, however the packet is dropped as calling WTSVirtualChannelRead again will read the next packet instead.

Using WTSVirtualChannelQuery to replace the calls to WTSVirtualChannelRead and WTSVirtualChannelWrite with ReadFile and WriteFile seems to fix the issue, but is a much more complicated process. Is there any way to get WTSVirtualChannelRead to work correctly instead?

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,473 questions
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,593 questions
{count} votes