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;
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;