Asynchronous I/O models of wsaasyncselect and Windows clients

Source: Internet
Author: User

Why use wsaasynselect?
The I/O model of the server is usually the select, poll, epoll, or iocp, and AIO asynchronous I/O model. This is undoubtedly a reasonable choice on the server side. What about the client? Is it reasonable or necessary to use select or AIO? Considering that the client always needs a UI thread, if you need to use the above solution, it is troublesome to introduce another thread to do this work, communicate between threads, and synchronize resources. The multi-threaded design makesProgramIt becomes complicated and difficult to debug. Isn't it possible to use a single thread to implement the entire client? In fact, wsaasynselect provided in Windows can easily implement UI and asynchronous Io processing in a thread. Wsaasyncselect is a method that best suits windows operating models. It can map the socket messages to the message loop of the thread. This complies with the Windows philosophy of "Don't call me, I will call you.

 

How to Use wsaasynselect?
Specific usage refer to msdn: http://msdn.microsoft.com/en-us/library/ms741540
To put it simply, you specify a target window through this API and register the socket and IO events that you need to care about, system (ws2_32.dll) A message will be sent to your window after this event occurs. wsagetselectevent (lparam) can be used to obtain the network event itself, while wparam is used to pass the socket handle. Then, you can actively call the socket function to handle these events. However, the main body of a Windows application always needs a simple loop to process and distribute messages.

 

about casyncsocketex
This is an encapsulation class for the wsaasynselect method and can be easily added to SSL and Proxy Support. The base class of most Communication classes of eMule is it. It uses a Help window to easily integrate existing projects. For more information, see http://www.codeproject.com/kb/ip/casyncsocketex.aspx.

Related Article

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.