0
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?

2
Contributors
2
Replies
14
Views
3 Years
Discussion Span
Last Post by Nandomo
0

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.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.