Re: Overlapped file IO

Dan Farino <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.clr
Message-ID <06CE4E670D914B46B61200C7B9733DDD60E71D@fegplmsexmb13.ffe.foxeg.com>
Hmm...sounds like our definitions of "overlapped" are a bit different
here. 

I interpreted it as just meaning passing in the flag
FILE_FLAG_OVERLAPPED (which is the same numeric value as
FileOptions.Asynchronous) to CreateFile and using the OVERLAPPED
structure for performing async I/O with ReadFile and WriteFile.

So while you can't touch the fields of the OVERLAPPED struct yourself,
FileStream is using it under the covers to accomplish the async I/O.

-----Original Message-----
From: Discussion of development on the .NET platform using any managed
language [mailto:[email protected]] On Behalf Of Alex
Ivanoff
Sent: Monday, November 19, 2007 3:56 PM
To: [email protected]
Subject: Re: [DOTNET-CLR] Overlapped file IO

FileStream.BeginXXX/EndXXX methods are asynchronous, but not overlapped.
You cannot specify where to start reading/writing (Win32
OVERLAPPED.Offset/OffsetHigh members) nor can you issue multiple
read/write operations against the same file handle at the same time.
From MSDN:

"EndRead must be called exactly for every call to BeginRead. Failing to
end a read process before beginning another read can cause undesirable
behavior such as deadlock."

This is not overlapped at all.


-----Original Message-----
From: Discussion of development on the .NET platform using any managed
language [mailto:[email protected]] On Behalf Of Dan Farino
Sent: Monday, November 19, 2007 17:42
To: [email protected]
Subject: Re: [DOTNET-CLR] Overlapped file IO

Yes it does (except on Windows 9x). For FileStream, use the constructor:

public FileStream(string path, FileMode mode, FileSystemRights rights,
FileShare share, int bufferSize, FileOptions options)

Make sure you pass in FileOptions.Asynchronous. Then, use
BeginRead/Write and EndRead/Write. This uses overlapped I/O. (The only
part that is still synchronous is the constructor since there is no
async version of the underlying CreateFile Win32 call.)

Other classes such as Socket also use overlapped I/O when you use
BeginXXX/EndXXX. In the case of Socket and others, you don't need to
pass any special flags in like you have to with FileStream's
FileOptions.

-----Original Message-----
From: Discussion of development on the .NET platform using any managed
language [mailto:[email protected]] On Behalf Of Alex
Ivanoff
Sent: Monday, November 19, 2007 2:44 PM
To: [email protected]
Subject: [DOTNET-CLR] Overlapped file IO

Does .NET 2.0 have support for overlapped IO or do I need to implement
one myself?

Alex

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.