Code example for DatagramPacket

Methods: getAddressgetDatagetLengthgetOffset

0
    } 
     
	Bundle nextMessage(DatagramSocket serverSocket, boolean socketOK, String username, String ipaddress) {
		byte[] receiveData = new byte[1024];
		Bundle info = null;
		DatagramPacket receivePacket = new DatagramPacket(receiveData,
				receiveData.length);
		try { 
            serverSocket.receive(receivePacket);
            String output = new String(receivePacket.getData(), receivePacket.getOffset(), receivePacket.getLength());
            Log.i(TAG, "Receive packet: " + output + ". From: " + receivePacket.getAddress());
            /* 
             * TODO add the database fill data function 
             */ 
            //if (output == "done"){ 
            info = getXMLWebService(username, ipaddress);
            //} 
             
		} catch (Exception e) {
			Log.e(TAG, "Problems receiving packet: " + e.getMessage());
Stop searching for code, let great code find you!  Add Codota to your java IDE