Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Break ReadFile blocking

141 views
Skip to first unread message

Manoj

unread,
Nov 12, 2009, 12:40:31 AM11/12/09
to
How to break ReadFile() blocking?

The Server has created the synchronous pipe (no overlapped I/O) with
blocking enabled and sending data to client.
client is receiving data in seperate thread, now I want to stop
receiving data thread but its block by ReadFile() API and if I use
CloseHandle() it will not return.

CancelSynchronousIo function also return ERROR_INVALID_HANDLE error
code

due to some reason I dont want to use overlapped I/O in CreateFile()/
CreateNamedFile()

any clue for break ReadFile() blocking?

-Manoj

Todd Aspeotis

unread,
Nov 16, 2009, 4:13:55 PM11/16/09
to
What's wrong with peeking to see if there is data before calling ReadFile?
Then read that number of bytes, no blocking will occur.

http://msdn.microsoft.com/en-us/library/aa365779%28VS.85%29.aspx

hNamedPipe [in]

A handle to the pipe. This parameter can be a handle to a named pipe
instance, as returned by the CreateNamedPipe or CreateFile function, or it
can be a handle to the read end of an anonymous pipe, as returned by the
CreatePipe function. The handle must have GENERIC_READ access to the pipe.

lpTotalBytesAvail [out, optional]

A pointer to a variable that receives the total number of bytes
available to be read from the pipe.

"Manoj" <manoj....@gmail.com> wrote in message
news:24699e8a-46a3-42d9...@b25g2000prb.googlegroups.com...

0 new messages