On the Web server processes the request process

     Last night read a network of chapters of this book, describing the contents of a Web server on how to work and have some ideas, then recorded.

     Web server during the entire receive client requests can be divided into two portions, a first portion of connection requests from clients, and a second part of the actual connection process with the client. Specific content generally describe the first OS reads the Web server configuration file to initialize the configuration, and then wait for the first connection part, calls the OS itself Socket libraries to create a method inside the socket, the socket identified by descriptor in particular word location in memory, a descriptor at this time is the return value of the Listen method, then accept method is called a protocol stack, the parameter descriptor is 1, 2 returns the descriptor. When an external request comes in, the second call processing section, and a client communication module, similar to the new communication module out of a new object in the heap (heap), specifically designed to handle this communication client. Then the program continues to loop stack to accept the next request wait state. It should be noted at this point, while waiting for the connection module at the time of processing the first request, this time waiting for the connection module are in a suspended state, does not allow external access request.

    Procedure described above, may be analogous to welcome at the club lobby, hostess first wait before the store, when one by one the guests lined up when the first deal the first guest, and so the guests all the formalities Banqi, registration number plates are somehow, can be seen as a socket has been built, this time the front desk ledger will also record details of the guests, the same server OS kernel and there was a table set designed to record then word. After handled properly handed over to the subsequent things service workers to specific customer service accordingly. The hostess continues to wait for the next guest.

   In fact on reflection, when work encountered some problems difficult to solve, this time wide open look at the best brain, think about the example of life, then contact the system of the actual processing flow, chances are you can find it relatively good solution .

  (PS: for example that some purely personal brain-dong, help individuals understand, if you want to explore the deep-seated specific process, it is recommended reading for the wonderful honestly!)

 

Guess you like

Origin www.cnblogs.com/clare09/p/12484019.html