Hi
I have setup a server from which accepts request from a client about certain information. The client has to compose a request to the server with a username and account number that has to fit into a certain request format. I have managed to do this by defining the username and account number as string, defining their values, padding the empty space to fit the request format that the server accepts (username = 30 bytes account number = 10 bytes) and then send the request in a DatagramPacket.

The problem I have is the server sends back a range of different information in a DatagramPacket. For example the first 4 bytes of information are the reference numbers (for example 28, 45, 31, 124) then the next 30 bytes is the Username and so on.

How can I extract the appropriate numbers of bytes for each value (reference number, username ).

Can I read it all into one string then just split it up?

Many Thanks
Sam