Code example for DatagramPacket

Methods: getLength, setData, setLength

0
     * @return  Length of actual data received. 
     * @exception IOException If an error occurs while receiving the data. 
     ***/ 
    public int receive(byte[] data, int length) throws IOException
    { 
        __receivePacket.setData(data);
        __receivePacket.setLength(length);
        _socket_.receive(__receivePacket);
        return __receivePacket.getLength();
    } 
 
    /*** Same as <code> receive(data, data.length)</code> ***/ 
    public int receive(byte[] data) throws IOException
    { 
        return receive(data, data.length);
    } 
 
}