Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Multithreading advice, please...

Posted on 1998-10-13
3
Medium Priority
?
223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 140 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

722 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