Solved

Multithreading advice, please...

Posted on 1998-10-13
3
220 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
haveThree challenge 22 128
ERP and the other system process verification 5 26
Bartender label printing - switch on and off graphics 3 94
Increment column based of a FK 8 68
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.

752 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