title: General Daemon/Server Design - Best Practices (C/C++, Linux)
body: <p>These questions are quite general since they keep coming up for me in different situations. I'm hoping there are some basic principles/standard practices.</p>
  
  <p>The typical requirements:</p>
  
  <ol>
  <li>A program that acts like a "server", running in linux in the
  background (and runs almost non-stop. restarting perhaps daily or weekly)</li>
  <li>Handles client connections via some socket protocol</li>
  <li>Has startup configuration files</li>
  <li>Outputs to one or more log files</li>
  </ol>
  
  <p>My questions:</p>
  
  <ol>
  <li>Should I write the program as a "daemon"? What are things I should consider when choosing the daemon vs non-daemon route?</li>
  <li>Where in the linux folder hierarchy should the log files and configuration files go? Should I run it out of some user's home directory or a sub-folder in some user's home directory? Or perhaps I should make a new folder i.e. /my_server_abc/ and then run it from there, writing log files to that directory as well?</li>
  </ol>
  
  <p>Thanks</p>