Use fork to create a sub-process for persistent connection. I am waiting now. Urgent: Linux general technology-Linux technology and application information. The following is a detailed description. All the code on the server side. Waiting is always displayed during connection...
Where is it. There is no error during running. However, the webpage cannot be opened.
Is it waitpid? Or is fork () used incorrectly?
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
Void send_error400 (int clnt_sock)
{
Char protocol [] = "http/1.1 400 Bad request \ r \ n ";
Char server [] = "server: My HTTP Server \ r \ n ";
Char conn [] = "Connection: Close \ r \ n ";
Char clength [] = "Content-length: 1024 \ r \ n ";
Char ctype [] = "Content-type: text/html \ r \ n ";
Char message [] ="400 :\
Bad Request Method!";
Send (clnt_sock, protocol, sizeof (protocol), 0 );
Send (clnt_sock, server, sizeof (server), 0 );
Send (clnt_sock, conn, sizeof (conn), 0 );
Send (clnt_sock, clength, sizeof (clength), 0 );
Send (clnt_sock, ctype, sizeof (ctype), 0 );
Send (clnt_sock, message, sizeof (message), 0 );
}
Void send_error404 (int clnt_sock)
{
Char protocol [] = "http/1.1 400 Not Found \ r \ n ";
Char server [] = "server: My HTTP Server \ r \ n ";
Char conn [] = "Connection: Close \ r \ n ";
Char clength [] = "Content-length: 1024 \ r \ n ";
Char ctype [] = "Content-type: text/html \ r \ n ";
Char message [] ="404 FIle :\
Not found!";
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.