all groups > dotnet framework > january 2004 >
You're in the

dotnet framework

group:

BeginXXX / Async IO


BeginXXX / Async IO Chad Z. Hower aka Kudzu
1/31/2004 11:02:06 PM
dotnet framework: The docs are not clear on a few points, particularly one. And considering
that the excerpted Async examples on MSDN have a bad link to the master, and
tha the one complete example appears to have a small bug that it wont compile
(Havent tried it, but syntax in one spot looks wrong and does not match
others, nor compile when that one item is duplicated) Im left to guess.

BeginRead/Write accepts a length of bytes to read/write. It makes a call back
at a later time when this is "complete". You can then use EndRead to
determine how many bytes were read. EndWrite does not return a value.

a) Can the call back ever be made in which the number of bytes is less than
requested in BeginRead - yet it not be an error. That is its just calling
back to you to say "I did this much" and you have to call BeginRead again.
Similar to how non blocking sockets work in Winsock. Or, is it that if
EndRead ever returns less bytes than requested in BeginRead, it should be
considered an error.

b) Same question - but EndWrite. But since EndWrite does not return a size,
it should thus be assumed that writes are ALWAYS completed successfully when
the call back is made, unless EndWrite raises an exception.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"


ELKNews - Get your free copy at http://www.atozedsoftware.com
Re: BeginXXX / Async IO Chris Taylor
2/1/2004 2:15:14 AM
Hi,

The async read callback can be called before the requested number of bytes
have been read, in this case it is up to you to restart a new async read.

As for the async write, the EndWrite will block untill the requested number
of bytes have been sent. So even if the callback got called prematurely
(Which I doubt would happen!), the EndWrite call would block. So if unless
there has been an error, the requested bytes have been written to the stream
once EndWrite returns.

Hope this helps

--
Chris Taylor
http://dotnetjunkies.com/WebLog/chris.taylor/
[quoted text, click to view]

Re: BeginXXX / Async IO Chad Z. Hower aka Kudzu
2/10/2004 9:58:13 PM
"Chris Taylor" <chris_taylor_za@hotmail.com> wrote in
news:eLHlthF6DHA.1052@TK2MSFTNGP12.phx.gbl:
[quoted text, click to view]


Thanks. The MSDN docs should really be updated about this...


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"


ELKNews - Get your free copy at http://www.atozedsoftware.com
AddThis Social Bookmark Button