CFanatic

Go Back   CFanatic > Advance Programming > Network Programming

Join CFanatic Forum Now

Multi Threaded TCP Server design topic posted under Network Programming which is a part of Advance Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 01-29-2012, 06:21 PM
Junior Member
 
Join Date: Jan 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
abshah is on a distinguished road
| More
Multi Threaded TCP Server design

Hi,

I am trying to implement a TCP server which is a part of a larger project. Basically the server should be able to maintain a TCP connection with any number of clients (a minimum of 32) and service any client that requests servicing. In our scenario the thing is that it will be assumed that once the client is connected to the server, it will never close the connection unless some sort of failure occurs (e-g the machine running the client breaks down ) and it will repeatedly request service from the server. Same is the case with all the other clients i-e each will maintain a connection with the server and perform transactions. so to sum up the server will be at the same time maintaining the connection with the clients while simultaneously serving each client as needed and should also have the ability to accept any other client connections that want to connect to the server.

Now I implemented the above functionality using the select() system call of the berkely socket API and it works fine when we have a small number of clients (say 10). But the server needs to be scaled to the highest possible level as we are implementing it on a 16 core machine. For that I looked through various multi threading design techniques e-g one thread per client etc and the best one in my opinion would be a thread pool design. Now As I was about to implement that I ran into some problems: If I designate the main thread to accept any number of incoming connections and save each connections File descriptor in a data structure, and I have a pool of threads, how would I get the threads to poll that whether a particular client is requesting for service or not. The design is simple enough for scenarios in which client contacts the server and after getting the service it closes the connection so that we can pick a thread from a pool, service the client and then push it back into the pool for future connection handling. But when we have to service a set of clients that maintain a connection and request services intermittently, what would be the best approach to do this. All help will be much appreciated as I am really stuck in this. Thanks.
Reply With Quote
  #2  
Old 02-23-2012, 07:52 AM
Member
 
Join Date: Feb 2011
Location: CA, USA
Posts: 35
Thanks: 0
Thanked 4 Times in 4 Posts
johnBMitchell is on a distinguished road
| More
Re: Multi Threaded TCP Server design

TCP Server includes protocol system which manages all client connection with admin. You should change server setting as “Always on”, so that you can solve problem of “request services intermittently” and use any time.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Web design Tips SarahSEO Looking to hire 3 02-04-2012 02:10 AM
Web Design Problem weboutsourcingteam Introduce yourself 1 11-05-2011 10:30 PM
How to detect antivirus installed on windows 2003 server and 2008 server 2003 server sourabhfrndz C++ Programming 0 12-23-2010 11:10 PM
Multi-threaded Program Taking Longer To Execute Shard Win32 Programming 0 08-28-2010 03:00 AM
The design looks great. OthetAlable Introduce yourself 1 02-06-2010 11:12 PM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 03:42 PM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board