Code example for DatagramPacket

Methods: getAddress, getLength, getPort

0
	    socket.receive(packet);
	    String bufferJson = new String(bData, 0, packet.getLength());
	    BufferResponse br = new Gson().fromJson(bufferJson,
		    BufferResponse.class); 
	    bData = new byte[br.buffer];
	    packet = new DatagramPacket(bData, bData.length);
	    socket.receive(packet);
	} catch (IOException e) {
	    handleException(e);
	    return null; 
	} 
 
	p.setIpAddress(packet.getAddress().getHostAddress());
	p.setPort(packet.getPort());
	p.setData(bData);
 
	return p;
    } 
 
    private class BufferResponse { 
	public int buffer;