Sending and Receiving 2D Arrays java

前端 未结 2 1942
名媛妹妹
名媛妹妹 2021-01-15 12:00

What I would like to achieve by asking this question is to learn how to send and receive 2-Dimensional Arrays to another computer.

The context is that the <

2条回答
  •  轮回少年
    2021-01-15 12:25

    You should create an object out of it. It´s easier to handle afterwards.
    After that you serialize it, then you split it in smaller byte[] (if it´s bigger then 64 kb). You add some bytes to each packet, I prefer
    byte[0] = is splited?
    byte[1] + byte[2] = sendNumber (just for controlling, it increases after every sent object)
    byte[3] = how many parts your object has
    byte[4] = what part is it
    What you need else.
    Afterwards you can easily put the parts together.
    I have never used it but i also found a library know as kryonet (while googling).
    Have a look... google it properly.

提交回复
热议问题