Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
thanks for these quick responds .
I will try this time to clarify everything regarding the multithreaded server.
we were asked to implement a TCP server single or multithreaded "but the multithreaded will gain more credits",this TCP server has to connect to a client which is given as .exe file by the professor"i have no access for the code", the server should respond to the client requests which are echo ,reverse echo ,time stamp , synchronise and error.
just to mention that we are using three libraries "winsock.dll , WS2_32 AND WSOCK32"
if (connSock  = listener->Accept(client_addr)){
            ThreadData *data = new ThreadData ( this,
                                                connSock,
                                                client_addr );
            DWORD pth1 = _beginthreadex( NULL,
                                         0,
                                         ThreadedTCPServer::thread,
                                         data,
                                         0,
                                         &thID );
        }
        else
            break;
this is the part were I start the new thread and it will be handled by new connector socket not the same listner socket ...
so now if i try to check if its working properly i just added cou<<connsock;
but it was the same for each client that connects to the server .
all I am asking now is "how can I check if my code running as multithreaded or not ?? and if its multithreaded then do I have to use Roundrobin , Semaphore or Mutex ??and for what shall I use them because as far as i can tell i dont need to schedule the CPU because the each client connect to the server and send request to the server and recieve response and disconnect right away. if you need more details please dont hesitate to ask any questions.
Posted 27-Dec-10 11:03am
Edited 28-Dec-10 2:53am
v4
Comments
Dalek Dave at 27-Dec-10 18:37pm
   
Source code is allowed.
Sometimes obligatory, people will need to see it in order to help.
BUT! Don't do a code dump, just post the region giving the problem, as people hate trawling through 300 lines of code to fine the bug.
eng.spidy at 27-Dec-10 16:05pm
   
by the way if you need to see my source code I am ready to post it but I am not sure if this is legal according to the website policy
JF2015 at 27-Dec-10 17:39pm
   
Edited to improve readability.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

A multi-threaded server is expected to be superior to a single threaded one in the sense that it can handle multiple requests from clients simultaneously. I don't see how can those two programs 'handle the same amount of clients'.
 
Try adding some reasonably heavy calculation in the handler of socket receive event. The single-threaded server will be bogged down, while the multi-threaded one will continue to serve.
 
Your friend is probably not creating and running sockets on threads himself, but is using a library which does that for him.
 
More importantly, with this post of yours, it is not even clear what you want help with.
  Permalink  
Comments
eng.spidy at 29-Dec-10 0:30am
   
i updated the question please check it out if you still need more details just ask me so i can clarify it for you many thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 480
1 Maciej Los 290
2 Richard MacCutchan 225
3 BillWoodruff 185
4 Suraj Sahoo | Coding Passion 155
0 OriginalGriff 8,764
1 Sergey Alexandrovich Kryukov 7,437
2 DamithSL 5,639
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411028.1 | Last Updated 28 Dec 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100