A multithreaded tcp-based echo server implemented in C++
A multithreaded tcp-based echo server implemented in C++
In step 2, the argument 8000 is the port number on which the server will listen. You can pass any valid port number on which you want the server to listen. The server binds to all available ip addresses (INADDR_ANY).
The command in step 6 has two command line arguments. The first argument (127.0.0.1) is the ip address of the server. If the server is on another machine, then you can pass the ip address of that machine. The second argument is the port number on which the server is listening.
The client will take input from the user and send it to the server. The server will send the input back to the client.
The server is multithreaded, so it can handle multiple clients at the same time. The server creates a separate thread for each connected client.
When a client sends “exit” to the server, the server terminates the corresponding thread. The client also terminates.