I need to create a little client/server application that should transfer data like this:
statistic <- command type identifier
126.96.36.199 <- Statistic for this IP address
increase <- the kind of action that should be done with the address's statistic
6 <- Just some other parameters...
So there has to be one string that identifies the type of the command and then there should be some parameters depending on the command type. This parameters are different but always primitive data types. Most probably String, Short, Byte, Integer, and so on...
So there are instruction sets of different primitive data types.
My question is: Is it the best way to wrap the socket's streams in DataInput/OutputStreams and just read/write from them? Or is it better to save the messages into a byte array and then wrap this byte array in a
ByteArrayInputStream and wrap the ByteArrayInputStream in a
DataInputStream that I can read from? Or should I wrap the byte array in a
And if I wanted to encrypt my messages, would I have to save them as a byte array, then decrypt the byte array and then wrap it into some kind of data reader?