This is a Java program we made as an assignment part of the Big Data course I took in university. It uses Socket connection to input two matrices from two clients into a server and multiplies them. You can run the Server and Clients locally on the same device or run them on different devices in the same network.
-
If you are running Server and Clients on different devices you need to obtain the IP address of the Server device. Open the terminal on the Server device and execute:
-
On Linux:
hostname -I
-
On Mac:
ipconfig getifaddr en0
(en0
for wireless,en1
for wired connection)
-
-
Otherwise, if you are running Server and Clients on the same device, then the Server's IP address will be
localhost
Then proceed with the steps:
- Open
Server.java
file and change this line to choose the port you want to open aServerSocket
on (you can also leave it as1233
)
ServerSocket serverSocket = new ServerSocket(1233);
- Open
Client1.java
andClient2.java
files and modify this line to use the port you specified in the Server file and the IP address of the server you obtained
Socket socket = new Socket("localhost", 1233);
- Run
Server.java
and your console should printListening for client 1
, then runClient1.java
and you should see the first matrix printed on the server's console, then runClient2.java
and the second matrix should be printed then the multiplication result.