First, keep-alive mode1. The HTTP protocol uses "request-answer" mode, when using normal mode, that is, non-keepalive mode , each request/reply client and server to create a new connection, immediately after the completion of the connection (the
What is Keep-alive? OverviewBy default, HTTP links are usually closed after the request is complete. This means that the server closes the TCP link after the delivery of the response has been completed. To keep the link open to satisfy multiple
During webpage development, keep-alive is an important attribute in HTTP. We all know that HTTP is built on TCP. In the early implementation of HTTP, each HTTP request must open a socket connection. This is very inefficient because many HTTP
Code used to determine the end of an HTTP request in the Keep-Alive mode. Therefore, you can determine the end of a request based on EOF. the following code (PHP) is very common: Copy the code as follows: $ fp is the handle while (!) produced by
Determine the end of an HTTP request in Keep-Alive mode. When a short connection is used, each HTTP request corresponds to a TCP connection. after the request is complete, the connection is immediately disconnected, and the server returns EOF.
When a short connection is used, each HTTP request corresponds to a TCP connection. after the request is complete, the connection is immediately disconnected, and the server returns EOF. Therefore, you can determine the end of a request based on EOF.
When a short connection is used, each HTTP request corresponds to a TCP connection. after the request is complete, the connection is immediately disconnected, and the server returns EOF. Therefore, you can determine the end of a request based on EOF.
When using short connection mode, each HTTP request corresponds to a TCP connection, the connection is immediately disconnected after the request completes, and the server returns EOF. So you can judge the end of a request based on EOF, the
Therefore, you can determine the end of a request based on EOF. The following code (PHP) is very common:
Copy codeThe Code is as follows: // $ fp is the handle generated by fsockopen ().
While (! Feof ($ fp )){
Echo fgets ($ fp );
}
(Note: The short
So depending on the EOF to determine the end of a request, the following code (PHP) is common:
Copy Code code as follows:
$FP is the handle produced by Fsockopen ()
while (!feof ($fp)) {
Echo fgets ($FP);
}
(Note: The
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.