title: java.io.StreamCorruptedException: invalid stream header: 7371007E
body: <p>I have a client Server application which communicate using objects.<br>
  when I send only one object from the client to server all works well.<br>
  when I attempt to send several objects one after another on the same stream I get    </p>
  
  <pre><code>StreamCorruptedException.  
  </code></pre>
  
  <p>Can some one direct me to the cause of this error?</p>
  
  <p>client write method    </p>
  
  <pre><code>   private SecMessage[] send(SecMessage[] msgs) 
     {
       SecMessage result[]=new SecMessage[msgs.length];
        Socket s=null;
        ObjectOutputStream objOut =null;
        ObjectInputStream objIn=null;
        try
        {
         s=new Socket("localhost",12345);
         objOut=new ObjectOutputStream( s.getOutputStream());
         for (SecMessage msg : msgs) 
         {
              objOut.writeObject(msg);
         }
         objOut.flush();
         objIn=new ObjectInputStream(s.getInputStream());
         for (int i=0;i&lt;result.length;i++)
              result[i]=(SecMessage)objIn.readObject();
        }
        catch(java.io.IOException e)
        {
         alert(IO_ERROR_MSG+"\n"+e.getMessage());
        } 
        catch (ClassNotFoundException e) 
        {
         alert(INTERNAL_ERROR+"\n"+e.getMessage());
        }
        finally
        {
         try {objIn.close();} catch (IOException e) {}
         try {objOut.close();} catch (IOException e) {}
        }
        return result;
   }
  </code></pre>
  
  <p>server read method  </p>
  
  <pre><code>//in is an inputStream Defined in the server
  SecMessage rcvdMsgObj;
  rcvdMsgObj=(SecMessage)new ObjectInputStream(in).readObject();
  return rcvdMsgObj;
  </code></pre>
  
  <p>and the SecMessage Class is</p>
  
  <pre><code>public class SecMessage implements java.io.Serializable
  {
   private static final long serialVersionUID = 3940341617988134707L;
   private String cmd;
      //... nothing interesting here , just a bunch of fields , getter and setters
  }
  </code></pre>