Dear Readers,
Before you think this is about how to actually send a byte array via the Internet, I already know how to do that. What I need to know is how to actually send a packet like thing. I might actually use the wrong term, it might actually not be called a Packet. But anyways, I'll try to explain my problem;
I am about to create a Chat Application, in this Chat Application you can chat, I already know how to do that. But I want to take about a million steps further, I am going to add an abillity to use the Microphone, also I am going to add Usernames, Statusses and more. The only problem I've faced as I was creating this is making a method that allows to send different types of information.
This is how a TCP Server works:
Wait for byte[], Receive byte[], do following action, repeat.
I usually made the first byte in the byte[] to a certain number, for instance, byte 50 would mean a regular chat message, byte 60 would be a voice message. So that way, a client and the server know exactly what those byte[] are for. But this is really annoying and only works half of the time. Does anyone know a better way of doing this ?