Click here to Skip to main content
15,885,890 members

C++ multithreaded server

eng.spidy asked:

Open original thread
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.
Tags: C++, Multi-threading, Sockets

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900