I've got problems with implementing load
function in server.c
. I know general pseudocode, but when it comes to deciding which type variables do I need, I'm a bit stuck. Can someone help me with this?
1 Answer
When I hit my road block here, I went back to the source code and re-watched the walkthrough videos, specifically this one: https://www.youtube.com/watch?v=OnAItxJhS70
There are subtle hints throughout the video that made it all click for me. (It helped that I printed out the code to write notes on as I watched.)
In particular, study how request()
works. The pset gives this explanation:
Ah, this one’s a biggie. But worth reading through. When the server receives a request from a client, the server doesn’t know in advance how many characters the request will comprise. And so this function iteratively reads bytes from the client, one buffer’s worth at a time, calling
realloc
as needed to store the entire message (i.e., request).
Compare that paragraph to what the implementation of load
requires further down, and you should see connections that will help you move forward.