BTW the remaining buffer will automatically increase if the other side reads data out of it,right?
A:
How about PeekNamedPipe
? It would seem that the following will return the total number of bytes remaining to be read from the pipe.
DWORD totalBytesAvailable;
BOOL WINAPI PeekNamedPipe(
handle, // __in HANDLE hNamedPipe,
NULL, // __out_opt LPVOID lpBuffer,
0, // __in DWORD nBufferSize,
NULL, // __out_opt LPDWORD lpBytesRead,
&totalBytesAvailable, // __out_opt LPDWORD lpTotalBytesAvail,
NULL // __out_opt LPDWORD lpBytesLeftThisMessage
);
torak
2010-09-08 18:26:45
`totalBytesAvailable` includes bytes written by both sides of pipe,right?
Alan
2010-09-08 18:34:42
@Alan: I'm not sure. It says its the total available to read, which might mean just what this side of the pipe can read. However, I think that this is one of those cases where the easiest way to find out definatively will be to write some test code.
torak
2010-09-08 18:42:21
It doesn't work,I just tried,`totalBytesAvailable` is always `0`
Alan
2010-09-09 01:01:51