I can send an array from the Server Class to the Client class and read it, but I can not read a matrix.
Where is the error?
public class Client extends Thread {
InetAddress host = null;
Socket socket = null;
ObjectOutputStream oos = null;
ObjectInputStream ois = null;
//int arreglo[][] = new int[2][2];
public void run() {
try {
for (int x = 0; x < 1; x++) {
host = InetAddress.getLocalHost();
socket = new Socket(host.getHostName(), 4444);
oos = new ObjectOutputStream(socket.getOutputStream());
oos.writeObject("Client Message " + x);
ois = new ObjectInputStream(socket.getInputStream());
int[][] arreglo=(int[][])ois.readObject();
System.out.print(arreglo[0][0]);
ois.close();
oos.close();
socket.close();
}
} catch (Exception e) {
}
}
}
class Server extends Thread {
Socket socket = null;
ObjectInputStream ois = null;
ObjectOutputStream oos = null;
public void run() {
int[][] matriz2 = {{1,1},{1,1}};
//int[][] arreglo={{1},{2},{3}};
try {
ServerSocket server = new ServerSocket(4444);
while (true) {
socket = server.accept();
ois = new ObjectInputStream(socket.getInputStream());
String message = (String) ois.readObject();
System.out.println("Server Received: " + message);
oos = new ObjectOutputStream(socket.getOutputStream());
oos.writeObject(matriz2);
ois.close();
oos.close();
socket.close();
}
} catch (Exception e) {
}
}
}