I am having a hard time understanding the typical layout for a tcp server and would like some clarification on a few points. My understanding is that for a persistant server allowing only one connection at a time, there is an infinite loop that accepts a connection, and then a nested loop that continually gathers data into a buffer
i.e. while(read(sock, buffer, size...) > 0)

When the connection is closed, the inner loop will terminate and the client socket will be cleaned up. Then the server will loop back to the beginning and wait for another connection attempt on the listening socket.

If all of this is true and I would like to parse the incoming data and call other functions based on what was sent, where would I do so? Would the continual reading to the buffer block those function calls?

Basically, I would like for a client to be able to start a session with the server, send string commands to it, have the server detect and process them, and then send a result back. The client will issue many such commands in one session.