
-----------------------------------
greenapplesodaex
Sat Nov 15, 2008 11:17 am

how to tell a DatagramPacket's actualy size
-----------------------------------
I'm doing this assignment where you will continously receive 2 types of datagram packets in any order. 
the packets have different sizes (8 or 20 bytes), and doesnt seem to have data we can use as headers, is there a way to tell them apart?

because we dont know which size it will be, we have to allocate a byte
byte[] receiveData=new byte[44];
            try
            {
                
            	DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
            	routerSocket.receive(receivePacket);
                packetSize=receivePacket.getLength();
                System.out.println("length is "+packetSize);
                return receivePacket.getData();
            }
            catch (Exception e)
            {
            	//System.out.println("");
            }

im at loss of idea here....

so thanks in advance!

-----------------------------------
greenapplesodaex
Sat Nov 15, 2008 12:47 pm

RE:how to tell a DatagramPacket\'s actualy size
-----------------------------------
actually... nvm, there was a packet we get before this (and we can be sure the order and of that one) and that returned a whole bunch of garbage after the real data. it always filled up the whole thing and my observation was only based on that. the other 2 packets doesnt seem to do contain garbages, so everything works fine now
