10. Networking
Review the presentation Network
Tasks
- If necessary, change the value of the variable static final int port = 7700 in the class TttNet.java and the value of port in the src/resources/appplication.properties settings file to another number, e.g. 7701
- Explore the jtm.activity10 package
Run the TttCli class in a terminal to see how it works in a terminal using standard input and output:
java -cp target/classes/ jtm.activity10.TttCliand enter the cell numbers.
- Implement the TttNet class to run it as a server (if the port is available) or a client (a server is already listening on the port).
- When the class is running as a server:
Run TttNet in one terminal:
java -cp target/classes/ jtm.activity10.TttNetCheck if the server is listening by running the command in another terminal:
ss -ntlp|grep 7700Check how the server part works with the nc program as a client in another terminal:
nc 127.0.1.1 7700and it should work the same as TttCli, with the only difference
that the data is sent over a network socket.
When the TttNet class has a client part implemented, in another terminal:
java -cp target/classes/ jtm.activity10.TttNetit should work the same as TttCli, except that the data is sent over a network socket.
If necessary, check all running Java processes with the command:
ps -efaw|grep java- where pid is the process ID from the previous command
If necessary, you can stop the application with the command:
kill -9 pid