I'm currently trying to get a network game going.I'm using Sockets and Objekt Serialization, because thats what we are doing in class and I need to use them later in exams.After alot of working and trying out, I got the Server to send an Object and the Client to recieve it.

But for some miraculous reason, it will send the Object and recieve it, but will not update it.So its something client sided. Because the server only recieves the old object.

So it will send the Player Object: with x 100 and y 100. Eventhough I updated it on the client side to eg x 140 and y 132

Oh and when your checking it, maybe someone could tell me why I get two connections when connecting to the server?

EDIT: Found the problem. I needed to oos.reset(); the OutputStream, so it would disregard the object if it has been sent.

Ah yes, I forgot to mention in my earlier post that ObjectOutputStream checks to see if that object has already been sent and only notifies the other side about it. It doesn't send a new copy. Instead of using "oos.reset()", you need to use "oos.writeUnshared(Object)" and "ois.readUnshared()".

In my Player Class I have implemented a ArrayList<Missile>. Missile is a serializable Class and is just the missile.I can add missiles client sided, but when I send the Player class containing the ArrayList with missiles the arraylist ist empty.

This is fairly weird. Since I can send ArrayList with no problem on its own. Is there a certain method I have to use here?

if you want less text you could send byte messages... where you change move to a number and the symbols through a a few selected bytes...

You are absolutely right, defining an own simple text based network "protocol", would make things more deterministic, easier to debug and probably faster. On the downside, you can only send and receive data, your network code knows of.

Using serialization may have the advantage of being more abstract and you are getting the send and receive logic more or less for free.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org