I know that in java when u want to create a high performance serv开发者_JAVA百科er you use nio instead of the regular socket. So is there such a thing for C#, to create high performance servers?
Yes, SocketAsyncEventArgs
:
The
SocketAsyncEventArgs
class is part of a set of enhancements to theSystem.Net.Sockets.Socket
class that provide an alternative asynchronous pattern that can be used by specialized high-performance socket applications. This class was specifically designed for network server applications that require high performance. An application can use the enhanced asynchronous pattern exclusively or only in targeted hot areas (for example, when receiving large amounts of data).
You can use asynchronous sockets. If that one is not good enough, you can always check out the Network Direct SPI
, part of the HPC SDK. Note that Network Direct does require hardware-specific provider, though.
SocketAsyncEventArgs uses Windows I/O Completion Ports, which makes it fast. It is asynchronous, which makes it scalable. The really big deal with SocketAsyncEventArgs is I/O Completion Ports.
See http://www.codeproject.com/KB/cs/socketasynceventargs.aspx for how to use SocketAsyncEventArgs.
There are different ways of using the regular sockets. Typically, asynchronous use scales better.
精彩评论