Deserialisation issue - java.io.StreamCorruptedException: invalid type code: 00

后端 未结 2 446
既然无缘
既然无缘 2021-01-25 23:11

I\'m writing a java file-transfer app, and i have some troubles with deserialisation myself-defined class Message from Datagramms.

Other topics at StackOverflow has simi

2条回答
  •  [愿得一人]
    2021-01-25 23:41

    Are you sure you have received all of the bytes for the serialized objects? A DatagramSocket uses UDP under the hood. Are you sure that all of the packets have arrived?

    Also, is it really a good idea to use UDP for transferring a serialized object? This is one case where TCP would seem to be more approriate. UDP does not guarantee delivery or delivery order which could easily cause a corrupted stream.

    You should also really put a private static final long serialVersionUID = 1L; on your Message class.

提交回复
热议问题