I am trying to send a Deck object that I have created by subclassing the Vector class through a TCP/IP Connection…I’m not sure if i’m doing this correctly, however…the problem isn’t getting the deck SENT, i don’t think, but receiving it correctly is the problem…
The Client side code is as follows…
InetAddress server = InetAddress.getByName(“hippo”);
int port = 22222;
Socket socket = new Socket(server, port);
System.out.println("Connected to server...attempting to send deck");
ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
oos.writeObject(deck);
System.out.println("DeckSent");
oos.flush();
oos.close();
socket.close();
(I’m catching everything necessary…)
Please don’t poke too much fun at the code, i’m just beginning this TCP/IP stuff
anyways, i’m sure that the message is getting to the server…because the connection is made fine…
server code is as follows…
int servPort = 22222;
ServerSocket serverSocket = new ServerSocket(servPort);
while(true){
Socket inSocket = serverSocket.accept();
ObjectInputStream ois = new ObjectInputStream(inSocket.getInputStream());
Object possibleDeck = ois.readObject();
System.out.println("Checking for Instance");
if(possibleDeck instanceof Deck){
System.out.println("It's a Deck");
deck = (Deck)possibleDeck;
System.out.println("Deck Loaded..." );
}
else
System.out.println("It's not a deck");
ois.close();
serverSocket.close();
}
it gives the error message (which i will display in a sec) when it reaches the line: “Object possibleDeck = ois.readObject();”
The error message is as follows…
java.io.InvalidClassException: javax.swing.JComponent; local class incompatible:
stream classdesc serialVersionUID = 4775608949283930591, local class serialVers
ionUID = -7908749299918704233
I can’t seem to fix it…it might help to know if where the problem is rising…is it the WAY that i’m sending the object (basically, CAN I DO IT THAT WAY???)…or does it have to do with something else?..
any help is appreciated…even suggestions on how to fix it (sample code is always welcome…) …
if i’m not sending the object in the correct manner, what is the best (easiest, even) to send one object from one machine to another?..
Thanx for any help…
Russ