473,320 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

CreateIoCompletionPort C# equivalent

Hi,

I Wonder... What is the C# CreateIoCompletionPort equivalent? is there a managed IO completion mechanism? can I use 'System.Net.Sockets' in combination with an IOCompletion port?
Any pointers or samples will be appriciated...

Nadav
http://www.ddevel.com
Nov 16 '05 #1
10 6443
Nadav,

The BeginSend/EndSend, BeginReceive/EndReceive methods use IO completion
ports for their asynchronous implementation.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Nadav" <Na***@discussions.microsoft.com> wrote in message
news:DA**********************************@microsof t.com...
Hi,

I Wonder... What is the C# CreateIoCompletionPort equivalent? is there a managed IO completion mechanism? can I use 'System.Net.Sockets' in
combination with an IOCompletion port? Any pointers or samples will be appriciated...

Nadav
http://www.ddevel.com

Nov 16 '05 #2
Thanks for the immediate response, Still, I didn't find any class that provide the SAME functionality as an IO Completion port: using a completion port one may bind several File handles ( e.g. file, socket, stdout, ... ), to a single port, by doing so the system will use a single thread ( or multiple threads, equivalent to the amount of processors ) for all async tasks for the associated handles, this will achieve best performance by decreasing the amount of context-switches done...

Usage of BeginSend/BeginRecieve may ( internally ) use the IO Completion mechanism BUT doesn't enable the usage of a [SINGLE] IO Completion port for several asynchronous tasks, SOooo it doesn't fit the same manner described above... what should I do to achieve the functionality just described using the .NET framework???? any pointers/samples or ideas will be appreciated.

Nadav
http://www.ddevel.com

"Nicholas Paldino [.NET/C# MVP]" wrote:
Nadav,

The BeginSend/EndSend, BeginReceive/EndReceive methods use IO completion
ports for their asynchronous implementation.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Nadav" <Na***@discussions.microsoft.com> wrote in message
news:DA**********************************@microsof t.com...
Hi,

I Wonder... What is the C# CreateIoCompletionPort equivalent? is there a

managed IO completion mechanism? can I use 'System.Net.Sockets' in
combination with an IOCompletion port?
Any pointers or samples will be appriciated...

Nadav
http://www.ddevel.com


Nov 16 '05 #3
Thanks for the immediate response, Still, I didn't find any class that provide the SAME functionality as an IO Completion port: using a completion port one may bind several File handles ( e.g. file, socket, stdout, ... ), to a single port, by doing so the system will use a single thread ( or multiple threads, equivalent to the amount of processors ) for all async tasks for the associated handles, this will achieve best performance by decreasing the amount of context-switches done...

Usage of BeginSend/BeginRecieve may ( internally ) use the IO Completion mechanism BUT doesn't enable the usage of a [SINGLE] IO Completion port for several asynchronous tasks, SOooo it doesn't fit the same manner described above... what should I do to achieve the functionality just described using the .NET framework???? any pointers/samples or ideas will be appreciated.

Nadav
http://www.ddevel.com

"Nicholas Paldino [.NET/C# MVP]" wrote:
Nadav,

The BeginSend/EndSend, BeginReceive/EndReceive methods use IO completion
ports for their asynchronous implementation.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Nadav" <Na***@discussions.microsoft.com> wrote in message
news:DA**********************************@microsof t.com...
Hi,

I Wonder... What is the C# CreateIoCompletionPort equivalent? is there a

managed IO completion mechanism? can I use 'System.Net.Sockets' in
combination with an IOCompletion port?
Any pointers or samples will be appriciated...

Nadav
http://www.ddevel.com


Nov 16 '05 #4
"Nadav" <Na***@discussions.microsoft.com> wrote in message
news:33**********************************@microsof t.com...
Thanks for the immediate response, Still, I didn't find any class that provide the SAME functionality as an IOCompletion port: using a completion port one may bind several File handles ( e.g. file, socket, stdout, ... ), to asingle port, by doing so the system will use a single thread ( or multiple threads, equivalent to the amount ofprocessors ) for all async tasks for the associated handles, this will achieve best performance by decreasingthe amount of context-switches done...

Usage of BeginSend/BeginRecieve may ( internally ) use the IO Completion mechanism BUT doesn't enablethe usage of a [SINGLE] IO Completion port for several asynchronous tasks, SOooo it doesn't fit the samemanner described above... what should I do to achieve the functionality just described using the .NETframework???? any pointers/samples or ideas will be appreciated.


Why do you think that BeginSend/BeginReceive will use more that one IO
Completion port?

To get the functionality you described, use BeginSend/BeginReceive.

I think Job Objects are the only thing that would really require you to
create your own IO Completion port.

John Vottero
Nov 16 '05 #5
Thankd for your responce,
Why do you think that BeginSend/BeginReceive will use more that one IO
Completion port? Well, I Would excpect that usage of a single IO completion port will enable binding Stream objects ( e.g. FileStream ) to the ThreadPool object ( which uses a single IO Completion port ) preventing this, means that a process that use a ThreadPool and a Stream object will utilize [AT-LEAST] two Completion ports ( one for the stream and one for the ThreadPool )... Enabling association of stream objects with a ThreadPool will enable to achieve better performence...
To get the functionality you described, use BeginSend/BeginReceive.

I think Job Objects are the only thing that would really require you to
create your own IO Completion port.

John Vottero

Nov 16 '05 #6
"Nadav" <Na***@discussions.microsoft.com> wrote in message
news:71**********************************@microsof t.com...
Thankd for your responce,
Why do you think that BeginSend/BeginReceive will use more that one IO
Completion port? Well, I Would excpect that usage of a single IO completion port will

enable binding Stream objects ( e.g.FileStream ) to the ThreadPool object ( which uses a single IO Completion port ) preventing this, means that aprocess that use a ThreadPool and a Stream object will utilize [AT-LEAST] two Completion ports ( one for thestream and one for the ThreadPool )... Enabling association of stream objects with a ThreadPool will enable toachieve better performence...


When you call BeginRead or BeginWrite you are binding to a thread pool but
the Framework does it all under the covers. The AsyncCallback method that
you pass to BeginRead or BeginWrite is called on a ThreadPool thread. You
can open a thousand streams and issue a thousand BeginReads and you WON'T
have a thousand threads waiting.

ThreadPool also has the BindHandle method that binds a handle to the
ThreadPool. This associates the handle with the ThreadPool's IO Completion
port. You usually don't want to use that, you should use
BeginRead/BeginWrite on a stream or, if you have a handle (i.e. to a named
pipe), create a FileStream with the constructor that takes a handle and set
the "isAsync" parameter to the constructor to true. That handle will be
bound to the ThreadPool's completion port and you can use
BeginRead/BeginWrite.

As far as I know, the ThreadPool only uses one IO Completion port. It might
use more than one if it is trying to optimize throughput, for example, it
might use one IO Completion port for every CPU. The important thing is that
you don't care, the Framework is doing the "right thing".

Nov 16 '05 #7
Well, Thanks for your detailed response, I wonder... is there any 'formal' Microsoft documentation that explain how all Async Stream functionality is implemented in terms of IO Completion ports? Does what you say is based on some formal documentation or on common good scenes?

P.S.
Personally I think that taking as granted that the framework is "doing the right thing" is one of the down sides of using .NET, One is not able to really understand how things work... and this means that optimal performance is hard to be achieved, this cause development of performance critical applications to be developed in environments other then the .NET framework..., may be the .NET framework is not designed for performance critical applications in the first place… ( I don't know )…

"John Vottero" wrote:
"Nadav" <Na***@discussions.microsoft.com> wrote in message
news:71**********************************@microsof t.com...
Thankd for your responce,
Why do you think that BeginSend/BeginReceive will use more that one IO
Completion port?

Well, I Would excpect that usage of a single IO completion port will

enable binding Stream objects ( e.g.
FileStream ) to the ThreadPool object ( which uses a single IO Completion

port ) preventing this, means that a
process that use a ThreadPool and a Stream object will utilize [AT-LEAST]

two Completion ports ( one for the
stream and one for the ThreadPool )... Enabling association of stream

objects with a ThreadPool will enable to
achieve better performence...


When you call BeginRead or BeginWrite you are binding to a thread pool but
the Framework does it all under the covers. The AsyncCallback method that
you pass to BeginRead or BeginWrite is called on a ThreadPool thread. You
can open a thousand streams and issue a thousand BeginReads and you WON'T
have a thousand threads waiting.

ThreadPool also has the BindHandle method that binds a handle to the
ThreadPool. This associates the handle with the ThreadPool's IO Completion
port. You usually don't want to use that, you should use
BeginRead/BeginWrite on a stream or, if you have a handle (i.e. to a named
pipe), create a FileStream with the constructor that takes a handle and set
the "isAsync" parameter to the constructor to true. That handle will be
bound to the ThreadPool's completion port and you can use
BeginRead/BeginWrite.

As far as I know, the ThreadPool only uses one IO Completion port. It might
use more than one if it is trying to optimize throughput, for example, it
might use one IO Completion port for every CPU. The important thing is that
you don't care, the Framework is doing the "right thing".

Nov 16 '05 #8
"Nadav" <Na***@discussions.microsoft.com> wrote in message
news:82**********************************@microsof t.com...
Well, Thanks for your detailed response, I wonder... is there any 'formal' Microsoft documentation that explain how all Async Stream functionality is implemented in terms of IO Completion ports? Does what you say is based on some formal documentation or on common good scenes?
I haven't seen any detailed documentation in this area. Figuring out how
BindHandle works took a fair amout of guessing and testing.

P.S.
Personally I think that taking as granted that the framework is "doing the right thing" is one of the down sides of using .NET, One is not able to really understand how things work... and this means that optimal performance is hard to be achieved, this cause development of performance critical applications to be developed in environments other then the .NET framework..., may be the ..NET framework is not designed for performance critical applications in the first place. ( I don't know ).


Similar statements have been made about every advance in software
development. I'm sure you can get much better program performance out of
C++ code but, you get much better programmer performance with C#.


Nov 16 '05 #9
Thanks for your response, it is very helpful, So, can I conclude from what you are saying that ...ThreadPool.BindHandle is being called by Stream Objects ( e.g. FileStream ) upon async usage? do you know of any good .NET profiling tools that can verify this assumption? ( is it an assumption? )

Nadav
http://www.ddevel.com

"John Vottero" wrote:
"Nadav" <Na***@discussions.microsoft.com> wrote in message
news:82**********************************@microsof t.com...
Well, Thanks for your detailed response, I wonder... is there any 'formal'

Microsoft documentation that
explain how all Async Stream functionality is implemented in terms of IO

Completion ports? Does what you
say is based on some formal documentation or on common good scenes?


I haven't seen any detailed documentation in this area. Figuring out how
BindHandle works took a fair amout of guessing and testing.

P.S.
Personally I think that taking as granted that the framework is "doing the

right thing" is one of the down sides
of using .NET, One is not able to really understand how things work... and

this means that optimal
performance is hard to be achieved, this cause development of performance

critical applications to be
developed in environments other then the .NET framework..., may be the

..NET framework is not designed for
performance critical applications in the first place. ( I don't know ).


Similar statements have been made about every advance in software
development. I'm sure you can get much better program performance out of
C++ code but, you get much better programmer performance with C#.


Nov 16 '05 #10
"Nadav" <Na***@discussions.microsoft.com> wrote in message
news:E6**********************************@microsof t.com...
Thanks for your response, it is very helpful, So, can I conclude from what you are saying that ...ThreadPool.BindHandle is being called by Stream Objects ( e.g. FileStream ) upon async usage? do you know of any good .NET profiling tools that can verify this assumption?

( is it an assumption? )

I've seen several posts by Microsoft employees who state that
BeginRead/BeginWrite use IO Completion ports. I haven't seen a good
explaination of how they are used.

I don't know of any good .NET profiling tools but, for this test, you could
use Task Manager. Write a test that will open 1000 sockets, issue 1000
BeginReads (that will stall) and then look at your thread count.

Nov 16 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: John | last post by:
Is there an equivalent of COM on Linux that I can get through Python. My need is to have some sort of language independent component framework. I can think of CORBA but I have to have a server...
2
by: Michael Foord | last post by:
Please pardon my ignorance on this one - but I'm not certain how the sign bt is treated in python bitwise operators. I've trying to convert a javascript DES encryption routine into python. ...
3
by: Robert Dodier | last post by:
Hello, Here's a thought that I'm sure has already occurred to someone else, I just can't find any record of it yet. An XML document is just a more verbose and clumsy representation of an...
1
by: Vannela | last post by:
Is there any equivalent control in .NET for the Power builder DataWindow control? I am explaining the Datawindow architecture to some extent. Power Builder DataWindow Control has got different...
6
by: Frank Rachel | last post by:
So I can focus on the correct areas of research, I was wondering if someone could give me the .NET equivelents for this J2EE architecture: JSP's make calls to local JavaBean Controls. The...
7
by: Tim Conner | last post by:
Hi, I am an ex-delphi programmer, and I having a real hard time with the following simple code (example ): Which is the equivalent to the following code ? var chars : PChar; sBack, s :...
10
by: karch | last post by:
How would this C# contruct be represented in C++/CLI? Or is it even possible? PolicyLevel level = (enumerator->Current) as PolicyLevel; Thanks, Karch
9
by: Alan Silver | last post by:
Hello, I'm converting some old VB6 code to use with ASP.NET and have come unstuck with the Asc() function. This was used in the old VB6 code to convert a character to its ASCII numeric...
14
by: grid | last post by:
Hi, I have a certain situation where a particular piece of code works on a particular compiler but fails on another proprietary compiler.It seems to have been fixed but I just want to confirm if...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.