I just need some clarification of the order things have to be done when using ObjectStreams.
-
Do u have to use is.flush() on the ObjectInputStream before you read in, or after u read in or both?
-
Do u have to use os.flush() on the ObjectOutputStream before you send out, or after u send out or both?
-
Do u have to use is.close() each time you finish reading in?
-
Do u have to use os.close() each time you finish sending out?
Im asking this because when my client sends variable to the server, say x = 10, the server gets it and sends back the same value. The client then gets this variable back and prints it and it says “x = 10”.
Then the client sends a new value, x = 20, but the server just gets x = 10 and so send x = 10 back.
So basically my client/server setup works the 1st time, then after that, the server isnt really getting the new values from the client, its just receiving a packet from it but its not getting a new value form the ObjectInputStream. Im pretty sure its something to do with opening/closing ObjectInput/ObjectOutput streams.