Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8738979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:50:49+00:00 2026-06-13T10:50:49+00:00

So I have a server-client combo which is just supposed to pass a custom

  • 0

So I have a server-client combo which is just supposed to pass a custom Object back and forth. I’ using the ObjectInputStream and ObjectOutpustStream classes to achieve this.

Here is the server’s loop:

while((inputPosition = (Vector2i) objectIn.readObject()) != null) {
    Print.log("input line: " + inputPosition.toString());
    outputLine = "you moved to " + inputPosition.toString();
    out.println(outputLine);        
}

Where inputPosition is a Vector2i, a simple class that just holds 2 integers, x and y.

Here is the client’s loop:

while((serverOutput = in.readLine()) != null) {
    Print.log("Server says: " + serverOutput);
    position = calculatePosition(position, reader);
    Print.log("sending over: " + position.toString());
    objectOut.writeObject(position);
}

The calculate position method just looks like this:

private static Vector2i calculatePosition(Vector2i position, BufferedReader reader) throws IOException {
    Print.log("i just got this: " + position.toString());
    String entry = reader.readLine().substring(0, 1);
    if(entry.equals("w"))
        position.y++;
    else if(entry.equals("s"))
        position.y--;
    else if(entry.equals("a"))
        position.x--;
    else if(entry.equals("d"))
        position.x++;

    return position;
}

So here is what happens. I connect to the server, and after moving one coordinate successfully, it just get’s stuck on the same coordinate over and over:

Server says: Use wasd to move around.
i just got this: 5, 5
w
sending over: 5, 6
Server says: you moved to 5, 6
i just got this: 5, 6
w
sending over: 5, 7
Server says: you moved to 5, 6
i just got this: 5, 7
a
sending over: 4, 7
Server says: you moved to 5, 6
i just got this: 4, 7

You can see in the “sending over” line that the vector2i object on the client side is up-to-date, but the response I get from the server is just the same one over and over. There server’s log looks like this:

input line: 5, 6
input line: 5, 6
input line: 5, 6

It seems to be receiving the same data over and over, but according to my log, the client should be sending new data over.

Does anyone have an idea what I did wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:50:50+00:00Added an answer on June 13, 2026 at 10:50 am

    After you have sent an object once, it send a reference to that object. This means

    • if you mutate an object and send it again, you won’t see the changes
    • the Object Stream’s memory will grow and grow as it needs to retain a reference to every object which has been sent/received.

    The way to avoid both these issue is to call reset() regularly. The library can’t do this for you as it doesn’t know what it can be safely done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a client-server Silverlight application, which is use Socets. I have server appliaction
We have a Server/Client cybercafe management application which used to work fine on Windows
We have client server based app which saves user related data into a zip
I'm using Indy10 under Delphi2009. I have a server/client application, with TidTCPServer and TidTCPClient.
If I have a Server/Client application that both reference the same DLL which contains
I have a server\client application which needs to request two different remote proxies via
Our assignment is to have a server-client model.... We're supposed to check for a
I have a server-client application in which I can modify both codebases. The client
I have a server/client project, I am using C# for coding, WCF as server.
I have a server-client application that is using a datagram socket to exchange messages.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.