Category Archives: 科技

Multi thread server program

Multi thread server program

Examination and comparison of various classic network server architecture designs

Party driven is acquainted to the greater part of programmers, as well as the most widely used one is its software in graphical interface programming. In reality, in network programming, function driver can be extensively applied and deployed in server packages with higher relationship quantity and superior throughput, for example HTTP server application, FTP server system, and many others. In comparison using the classic community programming approach, occasion pushed can greatly lessen the source profession, improve the company reception ability, and boost the community transmission effectiveness.

 

Concerning the server design mentioned within this paper, the research community can find a great deal of implementation code, so this paper will not be restricted into the display screen and examination of supply code, but aim to the introduction and comparison with the product. The server design applying the libev event pushed library will give the implementation code.

 

This paper refers to string / time legend, only to show the thread does have blocking delay on each and every IO, but it really won’t assurance the correctness of delay ratio and IO execution sequence; also, the interface pointed out within this paper is simply the UNIX / Linux interface acquainted for the creator, as well as the home windows interface isn’t advised. Readers can check with the corresponding windows interface by on their own.

 

one. Blocking community programming interface

Almost all programmers initial connection with network programming are with the interface for example hear (), send (), recv(). Making use of these interfaces, it is easy to make the server / customer design.

Let’s suppose that we would like to build a simple server plan to supply content material solutions comparable to “one dilemma and 1 answer” to the single consumer.

Determine one. Simple one issue and a person response server / shopper design

Assessment and comparison of various basic network server architecture products

We discover that many socket interfaces are blocking. The so-called blocking interface signifies which the technique call (typically IO interface) isn’t going to return the call end result and retains the present thread blocked. It only returns if the procedure simply call gets the result or perhaps the timeout error takes place.

 

In truth, unless of course if not specified, nearly all IO interfaces (such as socket interfaces) are blocking. This delivers a giant dilemma to community programming. For instance, when deliver() is referred to as, the thread will be blocked. In the course of this period, the thread will not be able to execute any operation or react to any network ask for. This brings troubles to your network programming of multi shopper and multi services logic. Right now, many programmers could pick multithreading to solve this problem.

 

Examples of a prototype design company can be found at Hemtom.

 

first joined the Company as Executive (Development) in 2003. He is a director of a number of subsidiaries and associated companies of the Company, and an Executive Director and Deputy Chairman of Tsim Sha Tsui Properties Limited and Sino Hotels (Holdings) Limited.

ATP offers comprehensive security services management to secure your business against data breach and cyber threats across endpoints

two. Multi thread server program

To handle the community software of multi shopper, the only answer should be to use multi thread (or multi approach) over the server side. The aim of multithreading (or multiprocessing) is always to make every relationship have its very own thread (or approach), so that the blocking of any link won’t have an affect on other connections.

There exists no distinct mode to utilize multi procedure or multi thread. Typically, the expense of a method is far better than that of threads. Therefore, in case you ought to offer services for additional purchasers with the exact same time, it is actually not proposed to work with various procedures. If an individual provider execution really should take in additional CPU means, including large-scale or long-term facts procedure or file entry, the method is safer. Typically, pthread is used_ Generate() generates a whole new thread and fork() generates a brand new method.

We presume that the server / shopper design has bigger requirements, that is definitely, the server can offer a person issue and one reply service for multiple purchasers with the exact time. So we have now the next model.

Recommended reading:

Evaluation and comparison of numerous common network server architecture styles

Event driven is common to your the vast majority of programmers, and the most favored just one is its software in graphi…