title: ObjectInputStream: is this correct way to unblock
body: <p>ObjectInputStream blocks when created until it recieves a serial input stream ans verifies it. I was trying to make my first program using sockets through it and found this. I used a dummy object so that it doesn't block. The code is here:</p>
  
  <pre><code>import java.io.*;                      
  import java.net.*;                     
  import java.util.*;                    
  
  class Dummy implements Serializable {
  }
  
  class X_Int implements Serializable {
      int x;
  }
  
  class Server {
          public static void main(String args[]) throws Exception {
                  ServerSocket ss = new ServerSocket(5879);
                  Socket client = ss.accept();
                  ObjectOutputStream out = new ObjectOutputStream(client.getOutputStream());
                  out.writeObject(new Dummy());
                  ObjectInputStream in = new ObjectInputStream(client.getInputStream());
                  in.readObject();
                  out.flush();
                  out.writeObject(new Date());
                  out.flush();
                  out.close();
          }
  }
  
  class Client {
      public static void main(String args[]) throws Exception {
          Socket server = new Socket("localhost", 5879);
          ObjectOutputStream out = new ObjectOutputStream(server.getOutputStream());
          out.writeObject(new Dummy());
          ObjectInputStream in  = new ObjectInputStream(server.getInputStream());
          in.readObject();
          out.flush();
          Date d = (Date)in.readObject();
          System.out.println(d);
      }
  }
  </code></pre>
  
  <p>Is this the right way. Please comment.</p>