Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What you're trying to do is called an Async Pattern in Microsoft terminology. The overall idea is to change all I/O blocking operations to non-blocking. If this is done, the application usually needs as many system threads as there are CPU cores at the machine.</p> <p>Take a look at Task Parallel Library in .Net 4: <a href="http://msdn.microsoft.com/en-us/library/dd460717%28VS.100%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/dd460717%28VS.100%29.aspx</a></p> <p>It's a pretty mature wrapper over the plain old Begin/Callback/Context .Net paradigm.</p> <p>Update:</p> <p>Think about what to you will do with the data after you read from the connection. In real life you probably have to reply to the client or save the data to a file. In this case you will need some C# infrastructure to contain/manage your logic and still stay within a single thread. TPL provides it to you for free. Its only drawback is that it was introduced in .Net 4, so probably it's not in Mono yet.</p> <p>Another thing to consider is connection's lifetime. How often your connections are opened/closed and how long do they live? This is important because accepting and disconnecting a TCP connection requires packet exchange with the client (which is asynchronous by nature, and moreover - a malicious client may not return ACK(-nowledged) packets at all). If you think this aspect is significant for your app, you may want to research how to handle this properly in .Net. In WinAPI the corresponding functions are AcceptEx and DisconnectEx. Probably they are wrapped in .Net with Begin/End methods - in this case you're good to go. Otherwise you'll probably have to create a wrapper over these WinAPI calls.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload