title: Multi threaded Linux Socket programming design
body: <p>I am trying to write a server program which supports one client till now and over the few days i was trying to develop it, I concluded i needed threads. The reason for such a decision was since I take input from a wifi socket and later process it and finally write to a file, the processing time is slow and hence i needed a input thread -> circular buffer -> output thread pattern with producer consumer model which is quite common in network programming.</p>
  
  <p>Now, The situation becomes complicated, as I need to manage client disconnection and re connection. I thought of using pthread_exit() and cleaning up all the semaphores and then re initializing them each time the single client re connects.</p>
  
  <p>My question is that is this a efficient approach i.e. everytime killing the threads and semaphores and re creating them. Are there any better solutions.</p>
  
  <p>Thanks.</p>