How much data in Pipe?
-
How to determine how much data stored in pipe object without reading it with ReadFile, that is some equvalent that we are able to determine amount of bytes in internet windows socket to allocate buffer and read it all in one function call. 9ine
In your protocol you could make it so that the first few bytes help determine or provide the size for the next command. The other end of the pipe would then always write an atomic operation for the protocol size. You then have this common header for your protocol in which you would read first to determine the size of the next packet. You could do it in 2 steps or you could allocate a buffer which reads as much data as it can off and parses the protocol through and if a packet is cut off then simply re-read. If you want to ensure that you would never get the packet cut off then simply ensure that all packets are the same size and create the buffer as a multiple. Otherwise I do not know of an API to peek the amount of data in the pipe currently however it is a handle so you could attempt to experiment with some APIs to see what results they yeild. 8bc7c0ec02c0e404c0cc0680f7018827ebee