views:

308

answers:

3

I'm trying to use the Stream.BeginWrite Async I/O API in .NET for a high-throughput situation with many short messages. As such, a scatter/gather API will reduce the number of context switches (and CPU usage) tremendously. Does this API use the LPBUFFERS Win32 API at all? Is there an alternative API for Scatter/Gather I/O?

+1  A: 

I would be surprised if you could get to the scatter/gather api's from the BCL (it's for the l33t w1n32 haxx0rz, you know?), but there's always P/Invoke (which is suprisingly easy to use, I've found).

Simon Buchan
A: 

If you want to dig into the guts of the framework, there are a few ways to do it:

1) Reflector

2) MS recently opened up the source for debugging purposes, you can step into it with VS2008 if you enable the option under Debugging/Options/General

3) Koders.com seem to be hosting the framework source too:

http://www.koders.com/csharp/fidCE09E83BE706D0BD370658C3785E82D3A13FC2CE.aspx?s=flush()#L109

Marc
A: 

There is no way to do socket scatter/gather I/O in .NET. According to a MSFT blog post, there may be a similar API in .NET 4.5 (whatever that is...)

Shachar