I have a server and a client. The server receives two command strings: add or remove. If server receives add, it adds the object it receives from the socket to a local list. Is it acceptable to open two different streams consecutively to receive two different objects?
Example:
/* To read the command */
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
/* To read the object */
ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
No, that is not necessary.
StringisSerializable. You could do something like this:Just make sure you use
ObjectOutputStream.writeObjectto send both your command and object.