I am writing a program in java using sockets with UDP. For a number of reasons i am seeking to align the sizes of each UDP packet so they are uniform, i.e. each one is always (predefined) XYZ KB in size regardless of actual payload (which could be much less). How might this be easily achieved (via padding bytes?)
Share
Allocate a fixed size byte array, fill it with whatever data you have, then create a datagram packet from it.