Re: How to perform a non-blocking synchronous ReadFile call/operation with NDISPROT ?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Yes most of the links provide lot's of information about synchronous and
asynchronous I/O.

However there is no mention of "non blocking" synchronous I/O.

The only thing which seems to be about "non blocking" synchronous I/O are
these lines of text:

"
When reading from a communications device, the behavior of ReadFile is
governed by the current communication time-out as set and retrieved by using
the SetCommTimeouts and GetCommTimeouts functions. Unpredictable results can
occur if you fail to set the time-out values. For more information about
communication time-outs, see COMMTIMEOUTS.
"

Bye,
Skybuck.

"Thomas F. Divine [DDK MVP]" <tdivine@xxxxxxxxxxxxxxxx> wrote in message
news:ejj2CYgfGHA.4464@xxxxxxxxxxxxxxxxxxxxxxx
Also, use the MSDN. A search for "ReadFile synchronous" brings up 500
topics (too broad a search...), BUT the first three in the list seem to
answer your question about how to perform synchronous/asynchronous I/O.

Thomas F. Divine, Windows DDK MVP
http://www.rawether.net

"Thomas F. Divine [DDK MVP]" <tdivine@xxxxxxxxxxxxxxxx> wrote in message
news:O1KK%23JgfGHA.3996@xxxxxxxxxxxxxxxxxxxxxxx
AFAIK the read will not complete until there is something to read. That's
the driver behavior. If you want a different behavior, then you will have
to modify the driver to suit your desires.

OTOH, your best bet is to start a thread that continuously performs reads
and queues the received packets (possibly throwing away unwanted ones).
You can examine the queued packets without blocking. Either there are
some to lookat - or there aren't.

The behavior is much like reading from a file (either synchronously or
asynchronously). If you make a ReadFile call, it won't complete until
you've read something.

Thomas F. Divine, Windows DDK MVP



"Skybuck Flying" <spam@xxxxxxxxxxx> wrote in message
news:447248ec$0$713$5fc3050@xxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello,

My question is the same as the subject:

How to perform a non-blocking synchronous ReadFile call/operation with
NDISPROT ?

According to Microsoft's documentation ReadFile can be used for
synchronous and asynchronous operation.

However the ReadFile documentation doesn't really mention how to perform
the synchronous operation.

It also doesn't really mention that ReadFile is initially blocking ?
Because during testing it seems to block.

If it is in the documentation for ReadFile than I surely missed it.

The only thing which hints at synchronous operation is the
link/mention/reference to the COMMTIMEOUTS documentation.

This is probably more of a general windows programming topic. But still
who knows what quarks NDISPROT might have ;)

How are synchronous operation with ReadFile done generally ?

Am I supposed to set a timeout ?

Is that the way to go ?

If so... will NDISPROT return partial packets because of a timeout or
will it buffer packets and only return full/whole packets/frames ?

I don't want to use asynchronous calls for now because that interrupts
the code flow. I simply want my code to move on and not have to deal
with callbacks, event handlers etc.

Is there any other method to prevent the blocking in a simple way...

Maybe using select() ? Or something like that ? Because select() is
probably only a winsock function ? ;)

Select also works with a timeout if I am not mistaken so the first
method is probably more or less the same idea.

Bye,
Skybuck.





.



Relevant Pages

  • Re: The Tcl notifier and Console on Windows
    ... ReadFile is expected to be used in blocking mode. ... The notifier itself does wait in an APC compliant ... All that's really important is that when the channel becomes serviceable ...
    (comp.lang.tcl)
  • Re: f0dders Fabulous Wait States.
    ... > The argument on the dependence on polling technology cannot be lost ... > for a very simple reason, with Von Neuman architecture (read ... >> are all blocking (with the exception of ReadFile in OVERLAPPED mode). ...
    (alt.lang.asm)
  • Re: about serial port communication and new operator
    ... It is unreliable to assume that you will receive a fixed number of bytes from ReadFile. ... if settings are wrong or the cable is disconnected a blocking call willl cause your entire program to lock up. ... It is best to use overlapped reads with timeouts, and buffer whatever number of bytes you receive, and reassemble and validate messages from multiple calls in your buffer. ... This article and associated sample code do serial communication well: ...
    (microsoft.public.vc.mfc)
  • Re: Palatable Windows IO using Ada
    ... have seen for the Win32 API simply export the ReadFile and ReadFileEx ... Windows ReadFile isn't always blocking, it can be asynchronous, see ...
    (comp.lang.ada)
  • Re: async i/o question
    ... buffers to kernel module. ... Kernel mode fills the buffers when it has ... THIS IS ORDINARY 'BLOCKING' SYNCHRONOUS I/O. ...
    (comp.os.linux.development.system)