I have an assignment for school where i have to make an application working through the network. We can do it in either Java or C ( or both ). We've been given an exact protocol to communicate between computers. Here is an example of a message of this protocol :
[REGIS␣id␣port␣pass+++]
On this message, id must be exactly on 8 bytes, port on 4 bytes , pass on 2 bytes, REGIS on 5 bytes and +++ on 3 bytes. To read this message, i use an InputStream object and the read() method, so i get a byte[] array.
My question is : can i construct a String object directly from the byte [] array and use a regex to check if the message is correctly constructed ?
Other question is : can i make a String containing my message, and use String.getBytes() to send a byte array [] through the network ?
My concern is about encoding : am i sure it will make 1 byte for every character ? Won't i have a problem if the message is read by a C program ?
Thank you for your help !