Przesyłam cała tablice zserializowaną, ale przesyła ją błędnie. Co tu jest nie tak ?
Przechwytywanie tablicy:
import java.io.Serializable;
import javax.swing.JButton;
public class Tablicas implements Serializable {
JButton [][] x = null;
public Tablicas(JButton [][] x) {
this.x = x;
}
public JButton[][] ret(){
return x;
}
}
Serwer :
try {
serverSock = new ServerSocket(5000);
clientSock = serverSock.accept();
System.out.println("Got a connection. \n");
if(on = true)
odbior();
} // end try
catch (Exception ex)
{
System.out.println("Error making a connection. \n");
} // end catch
}
void odbior() throws IOException, ClassNotFoundException{
ObjectInputStream ois = new ObjectInputStream(clientSock.getInputStream());
JButton[][] Tab = (JButton[][]) ois.readObject();
}
Klient
void connect() {
try {
sock = new Socket(serverIP, Port);
Tablicas out = new Tablicas(przy);
ObjectOutputStream oos=new ObjectOutputStream(sock.getOutputStream());
oos.writeObject(out);
oos.flush();
} catch (Exception ex) {
System.out.println("Cannot Connect! Try Again. \n");
}
}