- Forum posts: 13
Apr 25, 2016, 1:16:04 PM via Website
Apr 25, 2016 1:16:04 PM via Website
I find that to receive data from DatagramSocket, I need a DatagramPacket, but to initialize a DatagramPacket object I need to pass it an initialized byte array, and the length of that byte array. Problem is such a byte array is of fixed size. However the datagrams my program is expecting to receive are not of a fixed size. They could be anywhere between 16 and 256 bytes in length.
How do I create a DatagramPacket with an auto-adjusting length, that I can then determine the length at the moment I receive the packet, so I can allocate the correct sized byte array based on this length? I don't want to be limited by being required to only send and receive fixed-length packets.
— modified on Apr 25, 2016, 1:17:13 PM
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.