Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7954389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:24:54+00:00 2026-06-04T03:24:54+00:00

Every connection requires one thread for each, and for now, we’re allowing only certain

  • 0

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.

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 < LIMIT, counter++ and return TRUE
5.Otherwise return FALSE

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.

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:24:56+00:00Added an answer on June 4, 2026 at 3:24 am

    There will be a /proc/[pid]/task (since Linux 2.6.0-test6) directory for every thread belonging to process [pid]. Look at man proc for documentation. Assuming you know the pid of your thread pool you could just count those directories.

    You could use boost::filesystem to do that from c++, as described here:

    How do I count the number of files in a directory using boost::filesystem?

    I assumed you are using Linux.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it necessary to close the connection of a tcplistener or tcpclient after every
t-sql, sql server 2008 My application must check connection status to database every 5
I'm working on a python script that starts several processes and database connections. Every
I'd like to ask your help on a longstanding issue with php/mysql connections. Every
Every now and again, I need to start the Django development server, and have
Every now and then (ahem...) my code crashes on some system; quite often, my
Goal: Remote control ssh server with one connection and multiple sessions or one persistent
When Using a thread-local database connection, closure of the connection is required when the
I am trying to write a socket server that forks for every connection. I
ExecuteNonQuery requires an open and available Connection. The connection's current state is closed. Why

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.