How to solve: sending UDP packet using Sendto() got “message too long”

后端 未结 3 611
执笔经年
执笔经年 2021-01-13 08:30

I want to use the sendto() API to send video and audio data through UDP packet. The sending buffer size I got using getsockopt() is 114688, however, sendto() returned -1 wh

3条回答
  •  自闭症患者
    2021-01-13 08:56

    Per @datenwolf's answer, you simply can't send more than 64k in a single UDP datagram, as that limit is implicit in the two-byte length field in the protocol.

    Furthermore, it's not actually a good idea to send even that much at once. You should limit your packets to the MTU on the path between the two ends (typically in the region of 1500 bytes or less) so that you don't get fragmentation in the IP layer.

    Fragmentation is bad - ok?

提交回复
热议问题