How to timeout from ReadFile reading from named pipe?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: How to timeout from ReadFile reading from named pipe?

  1. #1
    Join Date
    May 2002
    Location
    Lindenhurst, NY
    Posts
    867

    How to timeout from ReadFile reading from named pipe?

    How can I timeout from ReadFile when reading from a named pipe? I looked into the overlapped flag but the docs say it wont work with pipes in 95/98/Me. I also looked into ReadFileEx and that also says it wont work for pipes on 95/98/Me.

  2. #2
    Join Date
    Dec 2002
    Location
    Birmingham, England
    Posts
    23

    Re: How to timeout from ReadFile reading from named pipe?

    Hello Martin O,

    Have a look at:

    Code:
    SetCommTimeouts()
    or try something like

    Code:
    // Check if there is any data in the pipe to read
    if(PeekNamedPipe(hPipe, NULL, NULL, NULL, &dwBytesAvailable, NULL))
    {
           // There is data available so get it
           if(0 != dwBytesAvailable)
           {
                  ReadFile(...)
           }
    }
    and put a timeout loop around it.

    Hope this helps,

    Dave

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center