Jebiga StaMozed

+ Follow
since Aug 14, 2018
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jebiga StaMozed

Thank you so much Henry, that is exactly what was happening. That is exactly why serializing it by myself before sending helped it, because it created a new object every time because I was serializing it by myself. I deleted my serialization and I added outputStream.reset(); and now it works perfectly!
I didn't put any print statements here to show you, but, actually I'm making a multiplayer TicTacToe. The thing is, every time the game state changes, the server sends the two dimensional array of integers to tell the client the current game state. When I send the first update, it updates perfectly, but when I send the second packet. It just looks the same as the previous packet. BTW. I did debug it with printing out and it sends something different, but receives the old thing. I found a solution to this. Basically, before sending I serialize the array and then deserialize it by myself. It started working again, but I still don't understand why this happens.
I need to pass an int  array from the server  to the client many times.
The first time that I send the array, everything works perfectly, but when I send it the second time or third etc. it arrives to the client as the exact same array that I've sent the first time.

If I send first time: 1, 0, 0, 0
The client will receive: 1, 0, 0, 0

And no matter what I send afterwards, my client will always continue receiving 1, 0, 0, 0 forever.

You might think that there is a problem with my sockets, streams etc. but I doubt it because I tried sending other data that isn't arrays and it worked perfectly.
The way I fixed my problem was by turning the int[] to Integer[]. Now it all works, but I just don't understand how that is possible. Can somebody explain?

Here is the code of my connection class which is responsible for accepting packets and sending them.

By the way, I also checked if what I send is changing and if what I receive is really the same and it really is. As I said just turning the array from int[][] to Integer[][] fixed the problem, but I can't get why.

Thanks for help a lot!