title: Good architecture for a moderately simple TCP server
body: <p>I am planning on implementing a special purpose TCP server in C on Linux. After doing a little research, it looks like there are a few ways to do this, including single threaded, one thread per connection, and others. For the sockets, there are options like datagram vs stream, and blocking vs non-blocking.</p>
  
  <p>Most of the communication is going to look like:</p>
  
  <pre><code>Client: request id [request info]
  Server: status id [response info]
  </code></pre>
  
  <p>or</p>
  
  <pre><code>Client: request id [request info]
  Server: status id [response info]
  Client: additional request id [request info]
  Server: status id [response info]
  </code></pre>
  
  <p>Where everything is &lt;1kB and most things are &lt;512B. There may be many individual requests in a short time, however.</p>
  
  <p>So, how do I set up the server so it works most effectively (ie, doesn't hog resources, doesn't deny client requests)?</p>