Reputation: 639
in Java, UDP datagram packets uses a fixed size of byte array to send and receive streams through the network.
String.getBytes()
at the client side to send all data in one buffer, then at the server how know the exact length of packet or data I need to receive as all data I should receive ?plus: I know that UDP packet should not be too long (i.e. not exceeding 548 byte), that means slicing the data at client is more efficient.
Upvotes: 1
Views: 1992
Reputation: 7374
Here is what I would do:
When each datagram is received, use the first 6 bytes to reassemble the datagrams into the complete data.
Upvotes: 2