Solved

Multithreading advice, please...

Posted on 1998-10-13
3
217 Views
Last Modified: 2013-11-19
Hi!!
  I'm finished a client-server application, which knows chat,
database access, whiteboard and so on, but the server is not multithreading. I have the next situation:
 - there is a class, which is derived from CSocket class, and manage the connection with the clients - the client class
 - I have one class, the Doc class, who receive on a specified port the clients, which are trying to access the server - the server class

Each client object have access to some data from the "server" class and vice-versa (each client have a pointer to the server class)
    I have some ideas to modify this program to obtain a multithreaded application:
 - to make a multiple inheritance when I derive the client class by using the CSocket and CWinThread classes
 - to use  worker threads for each client, and transfer to the treads a pointer to the server class
...
Please tell me, how can do  easier the multithreading in this situation??
0
Comment
Question by:visualc
3 Comments
 
LVL 2

Expert Comment

by:rayb
ID: 1323246
Hmmm...  Here's a real general comment...  Nearly every client/server application that I've ever worked on that relied on sockets, used a threading model like this:
The server has a main thread, which 'listens' for clients.  Once a client is detected a new thread is launched to service that client.
0
 

Accepted Solution

by:
seanowens earned 70 total points
ID: 1323247
Your question is not very clear or detailed.  Try to explain further what you need to know.  I don't think you're going to need to use multiple inheritance to solve your problem.  The comment from rayb is accurate.  The basic layout is
a) The main server thread listens on the socket
b) When a client connects to the server socket, the server thread wakes up, creates a new socket, accepts the connection, and does whatever else is necessary to set up the socket.  At THIS point the main server thread creates a new instance of the client manager object, puts the newly created socket into the client manager, and then spins off another worker thread.  You are going to need to do some kind of locking or user defined messages to communicate between server and client-manager, to avoid two threads accessing the same piece of code at the same time.  I suspect user defined messages will be better but thats really just a guess.  If you want more information contact me at player@envirolink.org.  
0
 

Author Comment

by:visualc
ID: 1323248
Hi, seanowens!!

I sent to you an e-mail!!!
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Whole sheet autoscrub still needed 19 51
while loop over for loop 7 104
matchUp  challenge 6 64
Updating statistics with error notification email in SQL server 4 96
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question