• 4622阅读
  • 3回复

QT设置UDP数据包大小 [复制链接]

上一主题 下一主题
离线themoonstone
 

只看楼主 倒序阅读 楼主  发表于: 2014-05-28
新人求教,我在做QT网络编程时应该怎么设置UDP数据包的发送大小啊
本帖提到的人: @Bai_Jianping @realfan @sdyansong
离线dbzhang800

只看该作者 1楼 发表于: 2014-05-28
正常情况下,你不需要设置这些底层的东西。
离线themoonstone

只看该作者 2楼 发表于: 2014-05-28
我是要做一个UDP测试软件,需要设置它的数据包的大小才行啊,你知道怎么做吗
离线dbzhang800

只看该作者 3楼 发表于: 2014-05-28
回 themoonstone 的帖子
themoonstone:我是要做一个UDP测试软件,需要设置它的数据包的大小才行啊,你知道怎么做吗 (2014-05-28 15:28) 

不清楚你的测试软件是测试什么的,为什么需要设置这个包的大小(或者 我理解的包大小和你理解的大小不一样?)。

QUdpSocket 内部没有使用buffer,所以他直接依赖你操作系统提供的buffer。【也就是说,你可以直接使用操作系统提供的API来操作它】

QUdpSocket does not use any buffering at all, but rather relies on the implicit buffering provided by the operating system

Datagrams are always written as one block. The maximum size of a datagram is highly platform-dependent, but can be as low as 8192 bytes. If the datagram is too large, this function will return -1 and error() will return DatagramTooLargeError.

Sending datagrams larger than 512 bytes is in general disadvised, as even if they are sent successfully, they are likely to be fragmented by the IP layer before arriving at their final destination.
快速回复
限100 字节
 
上一个 下一个