[quote]I’m trying to use a ReadableByteChannel and a damn ObjectInputStream fropm serverside trying to read a serialized object (an array of object parameters) sent by a client
the client simply write the object to a socket :
ObjectOutputStream oos=new ObjectOutputStream(socket.getOutputStream());
oss.write(new Param(arrayOfObjects)); // write my objects to the network
From the server side, I use selectors & keys, when I recieve my first read key, i’m
recieving a 4 bytes ByteBuffer !?, how nasty is this ObjectOutputStream ?
of course when I try to read the 4bytes with an ObjectInputStream I got an header exception
I start to think java serialization & network aren’t that friends, you know alternatives ?
[/quote]
-
Are you sure the server isn’t in non-blocking mode? That would explain why you received very little data in your first read…
-
WTF are you trying to do this? If you want to transfer objects, 99% of the time you’re better off using RMI (and it’s got a lot of useful features!). I know lots of people who are genuinely in the 1% situation (e.g. people who’ve needed more efficient implementations) but they tend to be pretty hard core situations. I’m not saying you definitely shouldn’t be doing this, just that you probably shouldn’t be :).
-
There are numerous documented (by Sun,usually in the API docs, usually quite in-your-face) incompatibilities with serialization between different VM versions. Are your client and server both using EXACTLY the same JVM version? e.g. 1.4.2_04, not merely 1.4.2, nor 1.4.x