From: Jimmie on
Is there any way to wait on data from a pipe? I see WaitNamedPipe
waits for a pipe's availability - that's not what I want.

I'd like to wait until data is available in a named pipe. Then, if
data does not arrive within a given timeout (say 5 seconds), return a
flag saying it timed out, and continue.

I can think of a few ways to accomplish this, but none are very
efficient. Anyone have any suggestions?
From: Doug Harrison [MVP] on
On Mon, 12 May 2008 06:45:46 -0700 (PDT), Jimmie <oskard(a)gmail.com> wrote:

>Is there any way to wait on data from a pipe? I see WaitNamedPipe
>waits for a pipe's availability - that's not what I want.
>
>I'd like to wait until data is available in a named pipe. Then, if
>data does not arrive within a given timeout (say 5 seconds), return a
>flag saying it timed out, and continue.
>
>I can think of a few ways to accomplish this, but none are very
>efficient. Anyone have any suggestions?

Pass FILE_FLAG_OVERLAPPED to CreateNamedPipe and use asynchronous I/O.


--
Doug Harrison
Visual C++ MVP
From: Jimmie Tyrrell on
On May 12, 12:26 pm, "Doug Harrison [MVP]" <d...(a)mvps.org> wrote:
> On Mon, 12 May 2008 06:45:46 -0700 (PDT), Jimmie <osk...(a)gmail.com> wrote:
> >Is there any way to wait on data from a pipe? I see WaitNamedPipe
> >waits for a pipe's availability - that's not what I want.
>
> >I'd like to wait until data is available in a named pipe. Then, if
> >data does not arrive within a given timeout (say 5 seconds), return a
> >flag saying it timed out, and continue.
>
> >I can think of a few ways to accomplish this, but none are very
> >efficient. Anyone have any suggestions?
>
> Pass FILE_FLAG_OVERLAPPED to CreateNamedPipe and use asynchronous I/O.
>
> --
> Doug Harrison
> Visual C++ MVP

Very helpful as usual Doug. FILE_FLAG_OVERLAPPED and and OVERLAPPED
data structure did the trick.

Thank you.