I want to built a UDP based Protocol which is able to send a file from a client to an server. The restriction is that the data which is send is exactly <x> bytes big. For example one packages should contain a 32-bit sessionnumber, a 8-bit packagenumber and a 10-byte large word in ASCII-Code.
I know that I have to initialize a byte-array which is in this case 15 bytes long but how can I write into it that I have the form I need?
byte[] array = new byte[15];
I tried to write "starting" in ASCII in the byte-array:
array[6] = 115;
array[7] = 116;
array[8] = 97;
array[9] = 114;
array[10] = 116;
array[11] = 105;
array[12] = 110;
array[13] = 103;
But it's not working how it should. Please give an explanation with your answer because I want to understand and learn with it.