. Net asynchronous socket (iocp) development)

Source: Internet
Author: User

Many people on the Internet have discussed. Net asynchronous socket communication.

Many people have misunderstandings and think that they have to use the iocp at the bottom of the system. In fact, it is not that troublesome. They must believe that. Net encapsulates all the underlying operations of the system.

In fact, Microsoft has an example of. Net iocp. The following is an example:

Class Server
{
Private Int M_numconnections; // The maximum number of connections the sample is designed to handle simultaneously
Private Int M_receivebuffersize; // buffer size to use for each socket I/O operation
Buffermanager m_buffermanager; // represents a large reusable set of buffers for All socket operations
Const Int Opstoprealloc = 2; // read, write (don't alloc buffer space for accepts)
Socket listensocket; // The socket used to listen for incoming connection requests
// Pool of reusable socketasynceventargs objects for write, read and accept socket operations
Socketasynceventargspool m_readwritepool;
Int M_totalbytesread; // counter of the total # bytes encoded ed by the server
Int M_numconnectedsockets; // The total number of clients connected to the server
Semaphore m_maxnumberacceptedclients;
... Omitted (refer to msdn, Baidu keyword Query Socketasynceventargs can be found in this example)
}
That is, the beginxxx (. net2.0) or receiveasync (. net3.5) methods defined by Microsoft for socket.

This is. Net port implementation.

The author developed a TCP server based on this, which can support 0.1 million concurrent online users.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.