Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #110

Re: detecting if space is available in a named pipe

From torri <vincent.torri@gmail.com>
Newsgroups comp.os.ms-windows.programmer.win32, comp.programming.threads
Subject Re: detecting if space is available in a named pipe
Date 2011-05-02 05:39 +0000
Organization Aioe.org NNTP Server
Message-ID <iplg29$9eh$1@speranza.aioe.org> (permalink)
References <ipiq5t$ihe$2@speranza.aioe.org> <IU.D20110502.T001822.P5669.Q0@J.de.Boyne.Pollard.localhost>

Cross-posted to 2 groups.

Show all headers | View raw


On Mon, 02 May 2011 01:18:07 +0100, Jonathan de Boyne Pollard wrote:

>> Is there some equivalent for writing (that is, a function that checks
>> if named pipe is not full). I would like to not use WriteFile for that.
>>
> WriteFile(), or even WriteFileEx(), is exactly what you should be using
> for that.  I can almost hear David Schwartz now: Think about what you
> are doing and why you want to know what you say you want to know.  The
> only real use for knowing whether there is "more room in the pipe" is to
> determine whether the next call to WriteFile() will block or not. That's
> the only thing that such information really tells you (and, depending
> from client-end application design, may not even tell you that fact). 

Ok. To be a bit more precise, I want to port a framework application from 
unix to windows (AF_UNIX connections). I try to mimic the code, but i'm 
realizing that I should use another design. It's not easy for me, as I'm 
not a Windows coder.

> Thus what you are really doing is trying to ensure that calls to
> WriteFile() never block, and that when they would your thread can do
> something else until the pipe drains, or at least wait for things other
> than just the completion of the write I/O request.  The proper design
> for this, which the MSDN Library documentation actually tells you to use
> pretty much explicitly, is to use overlapped I/O.  Use an overlapped I/O
> capable pipe handle, and WriteFile() with an OVERLAPPED structure to
> perform overlapped I/O.  You can continue doing things, or
> WaitForMultipleObjects() on both the overlapped I/O event and other
> things, and pump a new write request down the pipe whenever the
> preceding asynchronous one completes.

I won't touch overlapped I/O. It's an horror to correctly use. I've tried 
to use it, but documentation is very very very poor. I've lost 2 months 
trying to make it working correctly (in a specific case), i won't loose 
more time.

> Or, in other words: Don't design as if you can poll the pipe status and
> busy wait.  Design so that completion of a write request on the pipe is
> an event that you can block waiting for in amongst all of the other
> events that you might be waiting for.  Stick with the event-driven
> paradigm.

yes, that is what i'll do, i think.

thank you

Back to comp.programming.threads | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: detecting if space is available in a named pipe Jonathan de Boyne Pollard <J.deBoynePollard-newsgroups@NTLWorld.COM> - 2011-05-02 01:18 +0100
  Re: detecting if space is available in a named pipe torri <vincent.torri@gmail.com> - 2011-05-02 05:39 +0000
    Re: detecting if space is available in a named pipe David Schwartz <davids@webmaster.com> - 2011-05-02 03:55 -0700
      Re: detecting if space is available in a named pipe torri <vincent.torri@gmail.com> - 2011-05-02 17:02 +0000

csiph-web