title: StreamCorruptedException: unexpected EOF in middle of data block
body: <p>I am trying to make a client - server program using UDP.
  I am able to serialize the message from Server, and client also able to receive the message. But I don't know why, the client doesn't able to deserialize the message.</p>
  
  <p>In server side, i am sending a List to the others nodes.</p>
  
  <pre><code>    List&lt;Message&gt; messageToSend = new ArrayList&lt;Message&gt;();
      messageToSend.add(message);
  
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      ObjectOutput out = new ObjectOutputStream(bos);
      out.writeObject(messageToSend);
      byte dbByteSend[] = bos.toByteArray();
      out.close();
      bos.close();
  
      for(Entry&lt;Integer,String&gt; entry: test.getNeighbourList().entrySet()){       
          String IPaddress = entry.getValue();
          Integer portIP = entry.getKey();
              InetSocketAddress IPAddress = new InetSocketAddress(InetAddress.getByName(IPaddress), portIP);
              DatagramPacket sendPacketFirst = new DatagramPacket(dbByteSend,dbByteSend.length, IPAddress);
              Main.serverSocket.send(sendPacketFirst);
      }
  </code></pre>
  
  <p>In the client side, i am receive the message using this code:</p>
  
  <pre><code>        clientSocket.receive(client.receivePacket); 
          byte[] b = client.receivePacket.getData();
          List&lt;Message&gt; incomingMessages = gossip.serialization.deserializeByte(b);
  </code></pre>
  
  <p>here is the deserialize code:</p>
  
  <pre><code>     public List&lt;Message&gt; deserializeByte (byte[] data){
      List&lt;Message&gt; mapSer = null;
      try {
          ByteArrayInputStream filee = new ByteArrayInputStream (data);
          ObjectInputStream in = new ObjectInputStream(filee);
          mapSer = (List&lt;Message&gt;) in.readObject();
          in.close();
          filee.close();
      } catch (Exception e) {
          e.printStackTrace();
      }
      return mapSer;
  }
  </code></pre>
  
  <p>here is byte [] data value:</p>
  
  <pre><code>    [-84, -19, 0, 5, 115, 114, 0, 19, 106, 97, 118, 97, 46, 117, 116, 105, 108, 46, 65, 114, 114, 97, 121, 76, 105, 115, 116, 120, -127, -46, 29, -103, -57, 97, -99, 3, 0, 1, 73, 0, 4, 115, 105, 122, 101, 120, 112, 0, 0, 0, 1, 119, 4, 0, 0, 0, 1, 115, 114, 0, 14, 71, 111, 115, 115, 105, 112, 46, 77, 101, 115, 115, 97, 103, 101, -26, -73, 19, -11, -46, 85, 53, 114, 2, 0, 4, 76, 0, 9, 98, 108, 97, 99, 107, 108, 105, 115, 116, 116, 0, 16, 76, 106, 97, 118, 97, 47, 117, 116, 105, 108, 47, 76, 105, 115, 116, 59, 76, 0, 14, 109, 101, 115, 115, 97, 103, 101, 67, 111, 110, 116, 101, 110, 116, 116, 0, 19, 76, 106, 97, 118, 97, 47, 117, 116, 105, 108, 47, 84, 114, 101, 101, 77, 97, 112, 59, 76, 0, 16, 110, 101, 119, 78, 101, 105, 103, 104, 98, 111, 117, 114, 76, 105, 115, 116, 116, 0, 36, 76, 99, 111, 109, 47, 103, 111, 111, 103, 108, 101, 47, 99, 111, 109, 109, 111, 110, 47, 99, 111, 108, 108, 101, 99, 116, 47, 77, 117, 108, 116, 105, 109, 97, 112, 59, 76, 0, 4, 116, 121, 112, 101, 116, 0, 28, 76, 71, 111, 115, 115, 105, 112, 47, 77, 101, 115, 115, 97, 103, 101, 36, 109, 101, 115, 115, 97, 103, 101, 84, 121, 112, 101, 59, 120, 112, 115, 113, 0, 126, 0, 0, 0, 0, 0, 1, 119, 4, 0, 0, 0, 1, 115, 114, 0, 17, 106, 97, 118, 97, 46, 108, 97, 110, 103, 46, 73, 110, 116, 101, 103, 101, 114, 18, -30, -96, -92, -9, -127, -121, 56, 2, 0, 1, 73, 0, 5, 118, 97, 108, 117, 101, 120, 114, 0, 16, 106, 97, 118, 97, 46, 108, 97, 110, 103, 46, 78, 117, 109, 98, 101, 114, -122, -84, -107, 29, 11, -108, -32, -117, 2, 0, 0, 120, 112, 0, 0, 0, 9, 120, 115, 114, 0, 17, 106, 97, 118, 97, 46, 117, 116, 105, 108, 46, 84, 114, 101, 101, 77, 97, 112, 12, -63, -10, 62, 45, 37, 106, -26, 3, 0, 1, 76, 0, 10, 99, 111, 109, 112, 97, 114, 97, 116, 111, 114, 116, 0, 22, 76, 106, 97, 118, 97, 47, 117, 116, 105, 108, 47, 67, 111, 109, 112, 97, 114, 97, 116, 111, 114, 59, 120, 112, 112, 119, 4, 0, 0, 0, 1, 113, 0, 126, 0, 11, 116, 0, 5, 100, 97, 116, 97, 57, 120, 115, 114, 0, 43, 99, 111, 109, 46, 103, 111, 111, 103, 108, 101, 46, 99, 111, 109, 109, 111, 110, 46, 99, 111, 108, 108, 101, 99, 116, 46, 65, 114, 114, 97, 121, 76, 105, 115, 116, 77, 117, 108, 116, 105, 109, 97, 112, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 120, 114, 0, 46, 99, 111, 109, 46, 103, 111, 111, 103, 108, 101, 46, 99, 111, 109, 109, 111, 110, 46, 99, 111, 108, 108, 101, 99, 116, 46, 65, 98, 115, 116, 114, 97, 99, 116, 76, 105, 115, 116, 77, 117, 108, 116, 105, 109, 97, 112, 91, 110, -123, -4, 93, 54, 46, -91, 2, 0, 0, 120, 114, 0, 50, 99, 111, 109, 46, 103, 111, 111, 103, 108, 101, 46, 99, 111, 109, 109, 111, 110, 46, 99, 111, 108, 108, 101, 99, 116, 46, 65, 98, 115, 116, 114, 97, 99, 116, 77, 97, 112, 66, 97, 115, 101, 100, 77, 117, 108, 116, 105, 109, 97, 112, 33, -9, 102, -79, -11, 104, -56, 29, 2, 0, 0, 120, 112, 119, 8, 0, 0, 0, 3, 0, 0, 0, 5, 115, 113, 0, 126, 0, 9, 0, 0, 8, 57, 119, 4, 0, 0, 0, 4, 115, 114, 0, 16, 71, 111, 115, 115, 105, 112, 46, 78, 101, 105, 103, 104, 98, 111, 117, 114, 75, 81, 2, 112, -125, -57, 76, 114, 2, 0, 6, 73, 0, 4, 112, 111, 114, 116, 73, 0, 10, 116, 97, 114, 103, 101, 116, 80, 111, 114, 116, 76, 0, 13, 78, 101, 105, 103, 104, 98, 111, 117, 114, 76, 105, 115, 116, 116, 0, 19, 76, 106, 97, 118, 97, 47, 117, 116, 105, 108, 47, 72, 97, 115, 104, 77, 97, 112, 59, 76, 0, 9, 105, 80, 65, 100, 100, 114, 101, 115, 115, 116, 0, 18, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 83, 116, 114, 105, 110, 103, 59, 76, 0, 16, 110, 101, 119, 78, 101, 105, 103, 104, 98, 111, 117, 114, 76, 105, 115, 116, 113, 0, 126, 0, 5, 76, 0, 15, 116, 97, 114, 103, 101, 116, 73, 80, 65, 100, 100, 114, 101, 115, 115, 113, 0, 126, 0, 23, 120, 112, 0, 0, 0, 0, 0, 0, 4, 81, 112, 112, 115, 113, 0, 126, 0, 16, 119, 8, 0, 0, 0, 3, 0, 0, 0, 0, 120, 116, 0, 12, 49, 57, 50, 46, 49, 54, 56, 46, 48, 46, 49, 48, 115, 113, 0, 126, 0, 21, 0, 0, 0, 0, 0, 0, 4, 80, 112, 112, 115, 113, 0, 126, 0, 16, 119, 8, 0, 0, 0, 3, 0, 0, 0, 0, 120, 113, 0, 126, 0, 26, 115, 113, 0, 126, 0, 21, 0, 0, 0, 0, 0, 0, 31, -87, 112, 112, 115, 113, 0, 126, 0, 16, 119, 8, 0, 0, 0, 3, 0, 0, 0, 0, 120, 113, 0, 126, 0, 26, 115, 113, 0, 126, 0, 21, 0, 0, 0, 0, 0, 0, 4, 83, 112, 112, 115, 113, 0, 126, 0, 16, 119, 8, 0, 0, 0, 3, 0, 0, 0, 0, 120, 113, 0, 126, 0, 26, 115, 113, 0, 126, 0, 9, 0, 0, 4, 81, 119, 4, 0, 0, 0, 4, 115, 113, 0, 126, 0, 21, 0, 0, 0, 0, 0, 0, 8, 57, 112, 112, 115, 113, 0, 126, 0, 16, 119, 8, 0, 0, 0, 3]
  </code></pre>
  
  <p>when it run mapSer = (List) in.readObject(); it shows an error</p>
  
  <pre><code>    StreamCorruptedException: unexpected EOF in middle of data block
  </code></pre>
  
  <p>Can anyone help me and tell me where i did wrong?</p>
  
  <p>i tried to deserialize the message in Server using the same code, and it works, but I don't know why it isn't working in client.</p>