简体   繁体   中英

Java/Android: UDP - can't receive larger packets (but still < 64k)

I am working on a client-server android application (two applications - one client and one server). The server is expected to send a video to the client over UDP. I am dividing the video into individual frames, each of which end up being about 50,000 bytes, which is theoretically still less than the maximum for UDP.

I am currently testing on two Android emulators running on the same machine, and using UDP port forwarding in between to connect them.

I have set up the UDP such that if I send a byte array of ~5000 or less bytes, it works fine. If I attempt to send my frame byte arrays (50,000 bytes) the application freezes on the DatagramSocket.receive() method on the client.

Is there any way to set it up the UDP transmission to receive a larger byte size?

Thanks for your help.

But it isn't less than the practical maximum for UDP, which is 534 or 576 bytes, can't remember which at the moment, sorry. Whichever it is, that is the largest packet size that will avoid fragmentation. Once a UDP packet is fragmented into N fragments it is N times as likely to be lost.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM