What structure of data use to communicate via tcp/ip in java?

Posted by rmaster on Stack Overflow See other posts from Stack Overflow or by rmaster
Published on 2010-05-01T11:01:32Z Indexed on 2010/05/01 11:07 UTC
Read the original article Hit count: 207

Filed under:
|
|
|
|

Let's assume I want to send many messages between 2 programs made in java that use TCP sockets.

I think the most convienient way is to send objects like:

PrintStream ps = new PrintStream(s.getOutputStream());

ObjectOutputStream oos = new ObjectOutputStream(ps);

  some_kind_of_object_here;

  oos.writeObject(some_kind_of_object_here);

 ps.print(oos);

I want to send, strings, numbers, HashMaps, boolean values How can I do this using fx 1 object that can store all that properties? I though about ArrayList that is serializable and we can put there everything but is not elegant way. I want to send different types of data because user can choose from a variety of options that server can do for it. Any advices?

© Stack Overflow or respective owner

Related posts about java

Related posts about tcp-ip