Click here to Skip to main content
13,050,617 members (82,171 online)
Rate this:
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,
                                                client_addr );
            DWORD pth1 = _beginthreadex( NULL,
                                         &thID );

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 10:03am
Updated 28-Dec-10 1:53am
eng.spidy 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 27-Dec-10 17:39pm
Edited to improve readability.
Dalek Dave 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.

1 solution

Rate this: bad
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.
eng.spidy 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 28 Dec 2010
Copyright © CodeProject, 1999-2017
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