The main idea is that you have a buffer (a character array) where you store pieces of a message until you have a network newline ("\r\n"). Each message piece goes after the data that you've already placed in the buffer. When you find a network newline, you know that you have a complete message, so you can print that message and then shift any remaining bytes to the front of the buffer as the start of the next copy of the message.
while ((nbytes = read(fd, after, room)) > 0) {
    // Step 1: update inbuf (how many bytes were just added?)
    inbuf += nbytes;

    int where;

    // Step 2: the loop condition below calls find_network_newline
    // to determine if a full line has been read from the client.
    // Your next task should be to implement find_network_newline
    // (found at the bottom of this file).
    //
    // Note: we use a loop here because a single read might result in
    // more than one full line.
    while ((where = find_network_newline(buf, inbuf)) > 0) {
		// where is now the index into buf immediately after 
		// the first network newline
        // Step 3: Okay, we have a full line.
        // Output the full line, not including the "\r\n",
        // using print statement below.
        // Be sure to put a '\0' in the correct place first;
        // otherwise you'll get junk in the output.
        buf[where - 2] = '\0';

        printf("Next message: %s\n", buf);
        // Note that we could have also used write to avoid having to
        // put the '\0' in the buffer. Try using write later!

        // Step 4: update inbuf and remove the full line from the buffer
        // There might be stuff after the line, so don't just do inbuf = 0.

        // You want to move the stuff after the full line to the beginning
        // of the buffer.  A loop can do it, or you can use memmove.
        // memmove(destination, source, number_of_bytes)
        int rem = inbuf - where;
        memmove(buf, buf + where, rem);
        inbuf = rem;

    }
    // Step 5: update after and room, in preparation for the next read.
    after = inbuf + buf;
    room = sizeof(buf) - inbuf;

}