Allowing connections given the number of threads in server
<p>Every connection requires one thread for each, and for now, we're allowing only certain number of connections per period. So every time a user connects, we increment the counter if we're within certain period from the last time we set the check time. </p>

<pre><code>1.get current_time = time(0)
2.if current_time is OUTSIDE certain period from check_time,
  set counter = 0, and check_time = current_time.
3.(otherwise, just leave it the way it is)
4.if counter &lt; LIMIT, counter++ and return TRUE
5.Otherwise return FALSE
</code></pre>

<p>But this is independent of actually how many threads we have running in the server, so I'm thinking of a way to allow connections depending on this number.</p>

<p>The problem is that we're actually using a third-party api for this, and we don't know exactly how long the connection will last. First I thought of creating a child thread and run ps on it to pass the result to the parent thread, but it seems like it's going to take more time since I'll have to parse the output result to get the total number of threads, etc. I'm actually not sure if I'm making any sense.. I'm using c++ by the way. Do you guys have any suggestions as to how I could implement the new checking method? It'll be very much appreciated. </p>
