How do I flush a pipe under Windows ?
My GUI talks to child processes using pipes. I write into them using WriteFile(Handle, ...);
How can I flush such output pipes ?
Matthias.
How do I flush a pipe under Windows ?
Moderator: Ras
-
- Posts: 3245
- Joined: Thu Mar 09, 2006 9:10 am
How do I flush a pipe under Windows ?
My engine was quite strong till I added knowledge to it.
http://www.chess.hylogic.de
http://www.chess.hylogic.de
-
- Posts: 28387
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: How do I flush a pipe under Windows ?
Not sure what exactly you mean. The pipe must drain because the process at the other end reads what is queued in there. There is no way you can hasten that.
If you want to 'recall' what you wrote into the pipe, because you somehow regret it, you can keep a read handle to the pipe open in the sender process, and let it read back its own output. If a pipe as more readers, they fight for the data, and what one gets, the other one won't.
If you want to 'recall' what you wrote into the pipe, because you somehow regret it, you can keep a read handle to the pipe open in the sender process, and let it read back its own output. If a pipe as more readers, they fight for the data, and what one gets, the other one won't.
-
- Posts: 3245
- Joined: Thu Mar 09, 2006 9:10 am
Re: How do I flush a pipe under Windows ?
The internet is full of statements that the output pipe can be flushed, so that its contents are available for reading a bit earlier.hgm wrote:Not sure what exactly you mean. The pipe must drain because the process at the other end reads what is queued in there. There is no way you can hasten that.
If you want to 'recall' what you wrote into the pipe, because you somehow regret it, you can keep a read handle to the pipe open in the sender process, and let it read back its own output. If a pipe as more readers, they fight for the data, and what one gets, the other one won't.
As you say it's not possible, I'll take your word for it.
Thanks,
Matthias.
My engine was quite strong till I added knowledge to it.
http://www.chess.hylogic.de
http://www.chess.hylogic.de
-
- Posts: 567
- Joined: Sat Mar 25, 2006 8:27 pm
- Location: USA
- Full name: Robert Pope
Re: How do I flush a pipe under Windows ?
How about fflush() or _flushall()?
-
- Posts: 838
- Joined: Thu Jul 05, 2007 5:03 pm
- Location: British Columbia, Canada
Re: How do I flush a pipe under Windows ?
That is probably of interest only for remote pipes (over a network connection). Flushing the output pipe causes it to send the data in the buffer, otherwise it might sit around for a short delay for efficiency reasons. For local pipes it probably has no effect.Matthias Gemuh wrote:The internet is full of statements that the output pipe can be flushed, so that its contents are available for reading a bit earlier.
Anyway, you coud try the FlushFileBuffers function, as mentioned near the bottom of this article.
-
- Posts: 28387
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: How do I flush a pipe under Windows ?
Just to be clear: you can flush the _buffer_ that is holding data to go into the pipe, if you use buffered output. (And indeed, when you do not do that in GUI or engine, things come to a halt very quickly.) It transfers the data from the buffer to the pipe. I would not call that "flushing the pipe", and I don't think you meant that.
-
- Posts: 3245
- Joined: Thu Mar 09, 2006 9:10 am
Re: How do I flush a pipe under Windows ?
That is what I meanthgm wrote:Just to be clear: you can flush the _buffer_ that is holding data to go into the pipe, if you use buffered output. (And indeed, when you do not do that in GUI or engine, things come to a halt very quickly.) It transfers the data from the buffer to the pipe. I would not call that "flushing the pipe", and I don't think you meant that.

My engine was quite strong till I added knowledge to it.
http://www.chess.hylogic.de
http://www.chess.hylogic.de
-
- Posts: 28387
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: How do I flush a pipe under Windows ?
If you did not do that already, how could ChessGUI possibly have worked?
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: How do I flush a pipe under Windows ?
Or, as I do in Crafty, just use read()/write() which are, by standard, unbuffered. The engine-intf.html explanation in winboard/xboard covers this... Note that this is still a stream protocol, which means you may well not read everything that was sent from the remote end in one read() since large blocks get broken down into smaller packets, and a read() will read whatever is available, even if more is "on the way" from the remote end.Robert Pope wrote:How about fflush() or _flushall()?
-
- Posts: 3245
- Joined: Thu Mar 09, 2006 9:10 am
Re: How do I flush a pipe under Windows ?
I have been using ReadFile()/WriteFile() without bothering about buffering.bob wrote:Or, as I do in Crafty, just use read()/write() which are, by standard, unbuffered. The engine-intf.html explanation in winboard/xboard covers this... Note that this is still a stream protocol, which means you may well not read everything that was sent from the remote end in one read() since large blocks get broken down into smaller packets, and a read() will read whatever is available, even if more is "on the way" from the remote end.Robert Pope wrote:How about fflush() or _flushall()?
Now I will take a closer look.
My engine was quite strong till I added knowledge to it.
http://www.chess.hylogic.de
http://www.chess.hylogic.de