Sending an array over a socket with Java
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 n开发者_如何学编程ext 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.
If you are using Serialization, see the Javadoc for ObjectOutputStream.reset() and ObjectOutputStream.writeUnshared().
精彩评论