Being more explicit:
Maybe I dont understand the theory on DataOutputStreams. Anyway I am going to try to be more explicit.
When I have the following:
out.writeInt(x);
out.writeInt(y);
I believe that the x is sent first in a frame that includes the address where it should go etc (IP frame). And then the y is sent on another independent frame with its header, address where it should go etc.
So if the aforementioned is true, wouldnt it better to send x and y in only one frame. I could make my own protocol to hande the data. For example
out.writeUTF(P@X@Y);
When I receive something like this, I will break it into parts by using .split("@") and then check that if it has a “P” is a Positional message. So I know the other two data splitted are X and Y.
If I have a out.writeUTF(M@HELLO); , The M will tell me its a textMessage and I will take the rest of the content as a message.
Does anyone has donde something like this? Please help.