Question: You are required to implement a hybrid P2P chatting application using TCP socket programming. You are allowed to use the following three programming languages: C/C++,
You are required to implement a hybrid P2P chatting application using TCP socket programming. You are allowed to use the following three programming languages: C/C++, Java (Java 8), and Python (Python 3). You code should not be dependent on any development environment. That is, it should be compliable using command prompt (or shell) on Ubuntu (Bash) or MacOS.
Project Description
Phase 1 (8 points).
You are required to build a TCP socket based hybrid P2P chatting application.
In the demo, all of the clients and the servers will be running on the same machine. Therefore, their IP address would be 127.0.0.1 (loop back address) and DNS name is localhost.
SERVER SIDE. At the beginning, a server with a known IP (use a loopback address/DNS such as localhost) and a known port number (a fixed one) to clients. This information can be hard coded in the program code of the clients.
CLIENT SIDE. In this project, you will be required to start 5 clients along with the single server.
Each client should be initiated by typing
./client.out $ID $PORTNUMBER1 $PORTNUMBER2
Where $ID is the ID of the client and
$PORTNUMBER1 is the port number of the client to connect to the server, and
$PORTNUMBER2 is the port number of the client to listen from the other clients.
For each client, once it is connected to the server, they exchange a greeting message between a newly connected client and the server as well as existing clients. The exact message is Client $ID: initiated. Where $ID is the ID of the client. As mentioned above, the IP and the Port Number of the server can be hard-coded on the client side. Therefore, you can simply start the server by typing
./server
Now, once you start a server process and 5 client processes, and make them connected, you should be able to use either the server or one of the client to exchange messages among them. That is, a user should be able to type messages on one of them using the terminal, and that message should be broadcasted among them.
Finally, type a message Exit on the server. Then, the server should be terminated after a sending a message Server: terminated. to all of the clients. This message should be displayed on the screen of each client.
In order to receive 8 points, after the server is terminated, all clients should be able to exchange with each other.
To make to happen, while the server is in action, the clients should exchange its own listen port number with each other. As IP is 127.0.0.1, it is not necessary to exchange IP address.
It is important for the server to record the listening port number of each client as soon as it learns in a local text file which can be used for the Phase 2 of the project.
Phase 2 (8 points).
After the phase 2, you are required to restart the server. Then, each client should restore the connection between them and exchange the follow message between the server and each client (no broadcasting). This can be done by exploiting the listening port number of each client in the text file in Phase 1.
That is, Server: initiated should be sent to the client first, and this should be displayed on the screen of the client. Then, Client $ID: reconnected should be sent to the server, and this should be displayed on the screen of the server.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
