Sockets: sending structured data

As I understand, java sockets are able to send strings only.

I was wondering if java api have a class or something that allow me to send structured data.

Is there a native way in java api to send structured data over a network, i.e. without the need to parse myself string messages ?

Thanks.

[316 byte] By [Hermann.Richtera] at [2007-11-27 10:25:42]
# 1

Yes, look at Object Serialization.

lokiea at 2007-7-28 17:35:10 > top of Java-index,Core,Core APIs...
# 2

And I thought sockets only send/receive bytes...

also hava a look at ObjectInputStream and ObjectOutputStream.

S_i_m_ua at 2007-7-28 17:35:10 > top of Java-index,Core,Core APIs...
# 3

Also have a look at java.io.DataInputStream/DataOutputStream.

Where did you get the strange notion about only sending strings?

ejpa at 2007-7-28 17:35:10 > top of Java-index,Core,Core APIs...
# 4

mmm... I dont know really. That was long time ago. What matters anyway is that sockets can send only sequences of bytes.

Serialization is the perfect solution, though.

Thank you all.

Hermann.Richtera at 2007-7-28 17:35:10 > top of Java-index,Core,Core APIs...
# 5

> mmm... I dont know really. That was long time ago.

> What matters anyway is that sockets can send only

> sequences of bytes.

As opposed to what exactly?

What is stored on hard drives? bytes. What do you send through sockets? bytes.

If I were you I'd stop and make sure I knew what I was doing before I went much further because you seem a bit lost.

cotton.ma at 2007-7-28 17:35:10 > top of Java-index,Core,Core APIs...
# 6

>

> Serialization is the perfect solution, though.

>

And actually I kind of doubt this. Serialization may be what you need but I wouldn't say it's a perfect solution because there a bunch of problems it can create that you can avoid by doing other things.

cotton.ma at 2007-7-28 17:35:10 > top of Java-index,Core,Core APIs...
# 7

i'd hold out for socket osmosis expected in 1.7

developer_jbsa at 2007-7-28 17:35:10 > top of Java-index,Core,Core APIs...