Temp Remember Flashcards
1
Q
Implement CP1 ?
A
Create buff_stat (or buff info) { int Connection_fd; Buff[msg size per connection]; received;
}
buff_stat connections (or clients);
Upon receiving new connection: Call allocate (client socket) { Master fd update; Create a new connection of type buf_stat; }
Upon receiving new date;
{
Update_buff_stat(client socket) { Received; Remaining; Buff= ; if (buff conrains \r\n\r\n) Call parser; Get request line, header, body ready; Call send function() }
}
Send ()
{
Prepare the response and send it;
}
Upon receiving close signal
{
Master fd update (delete);
Remove the connection from buf_state;
}
2
Q
Implement CP2 ?
A
Upon receiving the request message, prepare the response:
- Check if the entire request is received
- Parse the request to find line, header, and body
- Prepare response message: line, header, and body.
- Get the body from the system and attach it to the message.
- Send.
3
Q
Implement CP3
A
4
Q
Cgi
A
Create input file for cgi (from the server)
Create output file for cgi (input to server)
Server: Open the file Clear input file Pass it the url info to input file Close file Call CGI
CGI: Open write file Clear it Get url from input file Prepare html result Write it to output file Close