
python udp socket.recvfrom(bufsize[, flags])(从套接字接收数据)
发布日期:2021-05-10 09:05:50
浏览次数:19
分类:精选文章
本文共 1020 字,大约阅读时间需要 3 分钟。
socket.recvfrom(bufsize[, flags])
Receive data from the socket. The return value is a pair (bytes, address) where bytes is a bytes object representing the data received and address is the address of the socket sending the data. See the Unix manual page recv(2) for the meaning of the optional argument flags; it defaults to zero. (The format of address depends on the address family — see above.)从套接字接收数据。 返回值是一对(字节,地址),其中字节是代表接收到的数据的字节对象,而地址是发送数据的套接字的地址。 有关可选参数标志的含义,请参见Unix手册页recv(2)。 它默认为零。 (地址格式取决于地址系列-参见上文。)
Changed in version 3.5: If the system call is interrupted and the signal handler does not raise an exception, the method now retries the system call instead of raising an InterruptedError exception (see PEP 475 for the rationale).
在版本3.5中进行了更改:如果系统调用被中断并且信号处理程序没有引发异常,则该方法现在重试系统调用,而不是引发InterruptedError异常(有关原理,请参阅PEP 475)。
规律总结
recvfrom()函数每次只接收一个数据报,数据报发送过来以队列形式存储在缓存中(我猜是这样??),然后函数一个个去取,如果recvfrom(BUFSIZE)中BUFSIZE的值小于当前取到的数据报报文长度,就会报这个错误(),如果recvfrom(BUFSIZE)中BUFSIZE的值大于当前取到的数据报报文长度,也就只返回这个报文,不会再往后取了。
发表评论
最新留言
哈哈,博客排版真的漂亮呢~
[***.90.31.176]2025年05月14日 00时43分56秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
linux下debug与release编译的方法
2023-02-02
linux下echo命令详解(转)
2023-02-02
linux下Emacs编译手记
2023-02-02
linux下FTP安装与配置
2023-02-02
linux下IPTABLES配置详解 [[转]]
2023-02-02
Linux下jvm、tomcat、mysql、log4j优化配置笔记
2023-02-02
LINUX下KVM的安装与配置
2023-02-02
linux下lamp的搭建及论坛的实现
2023-02-02
Linux下mail服务器应用之邮件系统
2023-02-02
Linux下mail服务器应用之邮件系统的安全性
2023-02-02
Linux下memcache的安装和启动
2023-02-02
Linux下mysql基本操作
2023-02-02
Linux下mysql常用操作命令
2023-02-02
linux下nc的使用
2023-02-02
Linux下php动态添加扩展
2023-02-02
Linux下ps -ef和ps aux的区别及格式详解
2023-02-02
linux下pthread_cancel无法取消线程的原因【转】
2023-02-02
Linux下putenv()函数导致composer更新失败
2023-02-02
linux下python找到自己编写的模块
2023-02-02