1 Reply Latest reply on Jun 28, 2007 8:19 PM by 807605


      Ok ,
      I did a little chat client/server software in java. In the last version i only used String. But now in version 2 I need to use Object (because with each message i need to send other info) but i always get the java.io.StreamCorruptedException But only on the client side! Here is a simplfy version of the my code (Throw the same exception ! )
      package ui;
      import object.*;
      import java.io.*;
      import java.net.*;
      import object.Message;
      public class Test {
           ObjectOutputStream oos;
           ObjectInputStream ois;
           public Test() {
                try {
                    Socket sock= new Socket("",5050);
                     oos= new ObjectOutputStream(sock.getOutputStream());
                              ois= new ObjectInputStream(sock.getInputStream());
                     Message m = new Message(2,"CONNECTION ESTABLISHED");
                     Thread threadLecture= new Thread(new LectureEntrants());
                } catch(Exception e1) {
           public class LectureEntrants implements Runnable
                public void run()
                     Message m;
                          while((m=(Message)ois.readObject()) !=null)
                     }catch (Exception e) {
      Error :
           at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1332)
           at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
           at ui.Test$LectureEntrants.run(Test.java:39)
           at java.lang.Thread.run(Thread.java:595)
      Can anyone help me ?
        • 1. Re: java.io.StreamCorruptedException
          I found my problem... Finally!
          If anyone have the same problem here wath was my error :
          On the server side (Take me long to figured it was there since the error was throw on the client side) I had 2 instance of my ObjectOutputStream (don't ask me why !!!) I removed one and now everything is working fine !