DatagramSocket SERVERSOCKET = new DatagramSocket(9999);

        byte[] receiveData = new byte[2000];

        while (true)
        {

            DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
            SERVERSOCKET.receive(receivePacket);
            String LINE = new String( receivePacket.getData());
            InetAddress iPAddress = receivePacket.getAddress();
            int port = receivePacket.getPort();
        }

Ok I have this right now, I have been googling, yet I do not know how to do a checksum of this UDP packet I am receiving. I do know the packet includes a header checksum. But I want a checksum for the DATA. Can anyone point me in the right direction?

Use the getData() method of the DatagramPacket class, wrap the resulting byte array in a ByteArrayInputStream, and use the MessageDigest class and its MessageDigest.getInstance("MD5"); and then DigestInputStream with the BAIS and the MD in the constructor and its digest method.

Lol you blew my mind. There is a lot of stuff I don't know how to use, so I'm going to start researching. Even though it doesnt solve my issue for now, it is a good heads up. I will see what I can do.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.