1

I have an 2-dimensional array to send over the socket The client is implemented so that it has 2 threads, one for rendering the swing gui and one for RECEIVING the data from server.

The server is implemented so that it has 2 threads, one for listening to incoming request and then put the request to another thread for processing the request (communicating with client)

Once the client interact with the swing gui, data will be constructed and sent to the server (actually, send to the thread which is in charge of processing the particular client), the server then processes the data and send back to client with a new data in an 2-dimensional array with updated information. The client can use the array to render the view.

However, when the first time the client send data, it ok, everything is fine. But the next time, client send new data, but it still receive the old one (server data is still updating)

I dont know if the problem is with the socket itself or the thread.

1
  • This is a very broad overview of what you're trying to accomplish, but doesn't include your implementation details, where this error most likely exists. It's worth noting that there are a lot of different ways to accomplish what you're asking, from Java specific mechanisms like Object Serialization to XML based solutions like REST and Web Services. It would be prudent to include the code which performs the sending and updating of your data on the client and server side. Commented Nov 30, 2010 at 6:14

1 Answer 1

2

If you are using Serialization, see the Javadoc for ObjectOutputStream.reset() and ObjectOutputStream.writeUnshared().

Sign up to request clarification or add additional context in comments.

1 Comment

I have modified to send data with readUnshared() and writeUnshared(), all the problems have gone now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.