I am trying to encode/decode a network packet combining the sender IP address, destination IP address, sender port, destination port and payload data all together.
I've been reading the different ways to do this and everywhere suggests using the Socket class - however, we can't use real network classes like this in our program because it's just a simulated application with no real networking components.
I'm confused on how else I would create a network packet WITHOUT using classes like DatagramPacket or DatagramSocket. The payload data is in byte[] form and the IP addresses are InetAddress. I'm assuming I might have to use some kind of ByteArrayOutputStream to combine all these elements into one network packet of type byte[].
Any suggestions for how I could do this would be really appreciated.
byte[]and be done with it? - Flexo