UGN Security

Java Object Serialize

Posted By: XGallagher

Java Object Serialize - 07/19/05 01:46 AM

Hi, I'm having a problem reciving serelized objects through a socket,

the code from the client is :

Socket SocketC = new Socket(ip,port);

//A class defined by myself that implements
SignedData Data=new SignedData(new String(b),dsa.sign(),pub);

ObjectOutputStream send = new ObjectOutputStream(SocketC.getOutputStream());

//sends the object SignedData
//sends a String object
//flushing the stream

//Reciving objects, code from server side

ServerSocket SocketS = new ServerSocket(port);
Socket client = SocketS.accept();

ObjectInputStream ois=new ObjectInputStream(client.getInputStream());

//Reciving the SignedData Object
SignedData signed = (SignedData)ois.readObject();

//Reciving the String Object
String cad = (String) ois.readObject();

//I also tried with the next line for reading the string instead of the one before
String cad = (String) ois.readUTF();

It's ok when reading the first object, but when trying to read the second I got this exception invalid stream header

it happends the same if I change the order of the objects (of course I change them at writing and reading) I dont know what the problem is, it can only read the first object
© 2017 UGN Security Forum