-
Open a terminal window.
-
If the client and server will be run on different machines, determine the server’s IP address:
- On Windows: run
ipconfig - On Linux/macOS: run
ifconfig - Look for the IP address in the form
192.168.x.xunder your active network adapter
→ The client must use this IP address.
If the client will be run on the same machine as the server, step 2 can be skipped.
- On Windows: run
-
Navigate to the directory containing the files
MakefileandTCPServer.java. -
In the terminal, run one of the following:
make run-server→ to use the default port6789make run-server PORT=<port>→ to use a different port
→ The client must use the same port.
- Open a terminal window.
- Navigate to the directory containing the files
MakefileandTCPClient.java. - In the terminal, run one of the following:
make run-client
→ if the server and client are on the same machine and the server is using the default port6789make run-client IP=<server-ip-address> PORT=<port>
→ if the server and client are on different machines or if the server is using a different port
- Repeat steps 1–3 for any additional clients.
PORT=<port>
If no value is given, the port number will default to 6789.
-
IP=<server-ip-address>
If no value is given, the IP address will default to 127.0.0.1
→ This will always work if the client and server are being run on the same machine. -
PORT=<port>
If no value is given, the port number will default to 6789
→ The port number for the client must match the port number used by the server.
-
make run-server
→ Port = 6789 -
make run-server PORT=6790
→ Port = 6790 -
make run-client
→ IP Address = 127.0.0.1
→ Port = 6789 -
make run-client IP=192.168.40.4
→ IP Address = 192.168.40.4
→ Port = 6789
Client → Server:
REQ|<client-name>|<expression>
Example:
REQ|Alex|3*4+8
Server → Client:
RES|<client-name>|<expression>|<result>
Example:
RES|Alex|3*4+8|20.0
Join Session (Client → Server):
JOIN|<client-name>
Example:
JOIN|Alex
Acknowledge Join (Server → Client):
ACK|Welcome <client-name>
Example:
ACK|Welcome Alex
Quit (Client → Server):
QUIT|<client-name>
Example:
QUIT|Alex
Disconnect (Server → Client):
No reply.
Join Log:
JOIN|<client-name>|address=<ip-address:port>
Example:
JOIN|Alex|address=/127.0.0.1:51756
Request Result Log:
RES|<client-name>|<expression>|<result>|processingTime=<ms>ms
Example:
RES|Alex|2+3*2|8.0|processingTime=1ms
Quit Log:
QUIT|<client-name>
Example:
QUIT|Alex
make run-client IP=192.168.40.4 PORT=6790
→ IP Address = 192.168.40.4
→ Port = 6790


