- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这个问题在这里已经有了答案:
How do I get amount of queued data for UDP socket?
(2 个回答)
3年前关闭。
哪一个ioctl
的 FIONREAD
返回,下一个数据包的长度,还是缓冲区中所有数据的长度?
假设有一个 UDP
服务器从客户端 1 接收 2 个数据包,并在客户端 1 的数据包之后从客户端 2 接收另外 2 个数据包。
那么,ioctl
的值是多少?的 FIONREAD
,
什么是readfrom
在这种情况下返回?
客户端 1:v 两个数据包
++UDP 服务器得到 4 个数据包 <- FIONREAD?
客户端 2 : ^ 两个数据包
FIONREAD? (服务器)
最佳答案
man udp (7)状态:
FIONREAD (SIOCINQ)
Gets a pointer to an integer as argument. Returns the size of
the next pending datagram in the integer in bytes, or 0 when no
datagram is pending. Warning: Using FIONREAD, it is impossible
to distinguish the case where no datagram is pending from the
case where the next pending datagram contains zero bytes of
data. It is safer to use select(2), poll(2), or epoll(7) to
distinguish these cases.
关于networking - UDP(数据报)套接字的 FIONREAD 返回什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16995766/
我正在将一些(套接字相关的)Windows C 代码移植到 Linux/Android,我遇到了 ioctl 命令的问题: unsigned long u; if(sockfd != -1 &&
这个问题与What does FIONREAD of udp socket return?有关 我尝试在 Mac 上使用下一个代码: if( ioctl(socketId, FIONREAD, &to
这个问题在这里已经有了答案: How do I get amount of queued data for UDP socket? (2 个回答) 3年前关闭。 哪一个ioctl的 FIONREAD返
我正在编写一个并行神经网络模拟器,我最近在我的代码中遇到了一个让我很困惑的问题(假设我只是一个中级 C++ 程序员,所以也许我遗漏了一些明显的东西?)。 .. 我的代码涉及一个“服务器”和许多客户端(
我在以下代码中看到了奇怪的行为: int len; ioctl(conn_fd, FIONREAD, &len); 您可能想象到的常见代码在此之前(它是一个玩具网络服务器): ... int sock
我遇到了一个非常奇怪的问题,我无法解决。我想使用 c++ 在 Mac Os X 上读取(仅读取)微 Controller 通过 USB 作为串口(FTDI)收集和发送的数据。一个完整数据序列的大小始终
我想知道我的 TCP 套接字中有多少字节可读。我正在使用标志“FIONREAD”调用 ioctl,它实际上应该给我这个值。 当我调用该函数时,我得到 return val 0 (所以没有 Error
打开文件描述符 fd 和/dev/random 的其他健全性检查后,我试图读取设备可读的字节数,以便在需要时提取此数量我的程序。 我的基本代码是这样的: if (fd = open("/dev/ran
我是一名优秀的程序员,十分优秀!