Code example for DatagramPacket

Methods: getData, getOffset

0
	// =========================================================== 
	// Methods 
	// =========================================================== 
 
	protected boolean verifyDiscoveryRequest(final DatagramPacket pDiscoveryRequest) {
		return ArrayUtils.equals(MAGIC_IDENTIFIER, 0, pDiscoveryRequest.getData(), pDiscoveryRequest.getOffset(), MAGIC_IDENTIFIER.length);
	} 
 
	protected void onDiscovered(final DatagramPacket pDiscoveryRequest) throws IOException {
		this.mSocketServerDiscoveryServerListener.onDiscovered(this, pDiscoveryRequest.getAddress(), pDiscoveryRequest.getPort());
	} 
 
	protected void sendDiscoveryResponse(final DatagramPacket pDatagramPacket) throws IOException {
		final byte[] discoveryResponseData = DiscoveryDataFactory.write(this.onCreateDiscoveryResponse());
 
		this.mDatagramSocket.send(new DatagramPacket(discoveryResponseData, discoveryResponseData.length, pDatagramPacket.getAddress(), pDatagramPacket.getPort()));
	} 
 
	protected void onStart() throws SocketException { 
		this.mDatagramSocket = new DatagramSocket(this.mDiscoveryPort);