StreamCorruptedException and Reliable Multicast

B

Bryan R. Meyer

I am working on an application that, in the most general terms, sends
a serialized object to a multicast group which is then reconstituted
using an ObjectInputStream on the receiving clients. This worked
fine.

I then decided to use the Java Reliable Multicast Service (JRMS) to
implement reliable multicasting in my application. Unfortunately, the
receiving clients are generating StreamCorruptedExceptions where the
reason is an "invalid stream header". The source code of JRMS
indicates that it handles data by sending it as bytes without
serialization. When the receiving client attempts to read the data,
it does not find a serialized object but rather data send by the JRMS
(which presumably handles the ack packets, etc.).

Is there a way to tell when the incoming data is an object or just
regular bytes? Or must I send my objects as non-serialized? That
would seem to make my job tougher, but I'd like to get this to work.
I've provided the portion of code where the receiver reads in an
object.

Any suggestions would be welcome.

Thanks,
Bryan

byte[] dataBuffer = new byte[8192];
DatagramPacket incomingMsgPacket = new
DatagramPacket(dataBuffer,dataBuffer.length);

if(!reliableMulticastOn) {
receiveSocket.receive(incomingMsgPacket);
}
else {
incomingMsgPacket = RMreceiveSocket.receive();
}
ByteArrayInputStream bytesToObject = new
ByteArrayInputStream(dataBuffer);
ObjectInputStream convertBytes = new ObjectInputStream(bytesToObject);
Object messageObject = convertBytes.readObject();
DistributedMessage incomingMsg = (DistributedMessage)messageObject;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top