The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how would you solve this problem? soemac UNIX for Advanced & Expert Users 7 03-29-2008 05:29 PM
How to solve restarting problem akzin UNIX for Advanced & Expert Users 2 06-13-2007 05:28 AM
Can any one solve this Problem...!!! Baba B. Saheb High Level Programming 9 10-10-2005 09:42 PM
can't solve that problem [PLEASE HELP] AiRkO UNIX for Advanced & Expert Users 2 01-22-2004 10:31 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 12-29-2003
Registered User
 

Join Date: Dec 2003
Posts: 6
Question How can I solve this problem?

I'm now designing a server application which can serve large number of clients' request. I've a question to ask, that is, main process will block when invoke the "accept" function, if a client request comes, main process should be separated into 2 processes by invoking "fork" function, the parent goes on with accept function, the child to serve the connected client's request. My question is, if there are large number of clients want to get connected with the server, the server application should be forked many times, is this harmful to our server resources?
Reply With Quote
Forum Sponsor
  #2  
Old 12-29-2003
Moderator
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,469
In case a thread library is available on your system, you may wish to use it instead of fork()ing because process switching is a more resource intensive than that of threads.
Reply With Quote
  #3  
Old 12-29-2003
Registered User
 

Join Date: Dec 2003
Posts: 6
Thank you for your answering

I've got your answer and now I want to make the confirmation. You mean that I should use thread instead of process to deal with clients' request, is that right?
Reply With Quote
  #4  
Old 12-30-2003
Moderator
 

Join Date: Dec 2003
Location: /dev/fl
Posts: 1,047
Correct. But be sure to use POSIX threads (Pthreads)

There are plenty of examples available on the Web
showing how to use POSIX pthreads to listen for
and handle incoming connections.

- Finnbarr
Reply With Quote
  #5  
Old 12-30-2003
Registered User
 

Join Date: Dec 2003
Posts: 6
Thank you for your reply

Roger that.
If you have interest in Threading process, we can discuss the ThreadPool architecture. You can contact me via email. My address is acqy@163.com, by the way, I'm also a novice.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:42 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0