Multi user TTT
| Prev | Next |
Main steps
Review theory
If necessary, review presentations:
Implement multiuser TTT server
- Investigate jtm.extra07 package
- The server reads the TCP port from the port key in src/main/resources/application.properties
- Implement class TttNetMultiuser:
- open a ServerSocket on the configured port,
- accept two client connections (Player 1 — ×, Player 2 — ○),
- start the game with new TttCli(input1, output1, input2, output2, size),
- run each pair of clients in a separate thread, so several games can run in parallel,
- close the client sockets when the game ends and log errors.
The optional first command-line argument is the board size, e.g.:
java -cp target/classes jtm.extra07.TttNetMultiuser 2Check server with nc (or telnet)
- Because you need two players, open two terminals and connect one client in each:
nc 127.0.1.1 7700To check if server is listening on necessary port, run:
ss -ntlp | grep 7700or:
netstat -antp | grep 7700- where pid is process id from the previous command
If necessary, server can be killed with:
kill -9 pid
| Prev | Next |


