title: EOFException in objectinputstream readobject
body: <p>i want to make a server  client application. i set everything up and i get this error. i want the app to wait till i get more data.</p>
  
  <pre><code>java.io.EOFException
  at java.io.ObjectInputStream$BlockDataInputStream.peekByte(Unknown Source)
  at java.io.ObjectInputStream.readObject0(Unknown Source)
  at java.io.ObjectInputStream.readObject(Unknown Source)
  </code></pre>
  
  <p>on the line:</p>
  
  <pre><code>listener.Received(inputstream.readObject(), id.ID);
  </code></pre>
  
  <p>Server code:</p>
  
  <pre><code>isrunning = true;
      Thread input = new Thread(new Runnable(){
          @Override
          public void run() {
              try{
                  ServerSocket Server = new ServerSocket(LocalPort);
                  while(isrunning){
                      Socket socket = Server.accept();
                      ObjectOutputStream outputstream = new ObjectOutputStream(socket.getOutputStream());
                      ObjectInputStream inputstream = new ObjectInputStream(socket.getInputStream());
                      Object obj = inputstream.readObject();
                      if(obj instanceof ID){
                          ID id = (ID) obj;
                          if(connctedChecker(id.ID)){
                              ID myid = new ID(ID, LocalIP, LocalPort);
                              outputstream.writeObject(myid);
                              connect(id.IP, id.Port);
                              listener.Connected(id.ID);
                              do{
                                  listener.Received(inputstream.readObject(), id.ID);
                              }while(socket.isConnected());
                              listener.Disconnected(id.ID);
                              closeConnection(id.ID);
                          }
                      }
                      inputstream.close();
                      outputstream.close();
                      socket.close();
                  }
                  Server.close();
              }catch(Exception e){
                  e.printStackTrace();
              }
  
          }
      });
      input.start();
  </code></pre>
  
  <p>Client code:</p>
  
  <pre><code>output = new Thread(new Runnable(){
          @Override
          public void run(){
              try {
                  socket = new Socket(RemoteIP, RemotePort);
                  inputstream = new ObjectInputStream(socket.getInputStream());
                  outputstream = new ObjectOutputStream(socket.getOutputStream());
                  ID id = new ID(ID, LocalIP, LocalPort);
                  outputstream.writeObject(id);
                  outputstream.flush();
                  Object obj = inputstream.readObject();
                  if(obj instanceof ID){
                      ID inid = (ID) obj;
                      RemoteID = inid.ID;
                  }
                  while(socket.isConnected()){
                      Object object = queue.take();
                      outputstream.writeObject(object);
                      outputstream.flush();
                  }
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
  </code></pre>
  
  <p>the listener:</p>
  
  <pre><code>public class Listener {
  
  public void Connected(UUID ID){
  
  }
  
  public void Received(Object object, UUID ID){
  
  }
  
  public void Disconnected(UUID ID){
  
  }
  
  }
  </code></pre>