C/S test system procedures for the production of detailed

Source: Internet
Author: User

Large-scale Job Defense: C/S test system procedures for the production of detailed

First, the server program

A WinSocket32 completion port model (I/O completion ports) is used

WIN32 Multithreading Technology

ODBC APIS for database operations

Second, the client program

Use the Win32 API function to construct the main form and interface elements, as shown in Figure one:

Diagram a program organization structure

Server program Detailed

A full port model (I/O completion ports) is by far the most complex I/O model, if a program needs to manage a large number of sockets, then this model can often achieve the best system performance, Unfortunately, the model only works with WIN2000 and Winnt operating systems, because of the complexity of the design, only if your application needs to manage hundreds of or even thousands of sockets at once, and you want to increase the number of CPUs installed in the system, the performance of the application can be linearly elevated to consider using the Complete port model (Web server is a typical example of this). I/O completion ports is the only technology that applies to a high load server, leveraging some threads to help balance the load caused by the I/O request, a framework that is particularly suitable for applications to generate so-called "scalable" servers in SMP systems ( Scalable is a system that can increase the efficiency of an application by increasing the amount of RAM or disk space and the number of CPUs.

The concrete implementation of the complete port model

In order to use the completion port model, I generated a bunch of threads waiting on the port, the number of threads =cpu x2+2, I associate the file handles generated by each client with the I/O completion ports port, and after this relationship is established, any client issuing an action request can cause i/ O completion packet was sent to the "completion port", which was done by the operating system, in response to I/O completion packet, I let I/O completion release a waiting thread, if there is no thread waiting, It will not generate new threads for this client n, and when the action thread finishes processing the "overlapped I/O" of the corresponding client, it will return the I/O completion port for waiting, and the client n can then be processed. This ensures that my workers thread always keeps a steady amount (the number of CPUs x2+2). As shown in Figure II:

Figure two complete port threading model diagram

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.