V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
zxCoder
V2EX  ›  问与答

c 语言 select 函数的文档里的这句话怎么理解

  •  
  •   zxCoder · 2021-06-01 16:53:05 +08:00 · 573 次点击
    这是一个创建于 1121 天前的主题,其中的信息可能已经有所发展或是发生改变。

    A file descriptor is considered ready if it is possible to perform a corresponding I/O operation (e.g., read(2), or a sufficiently small write(2)) without blocking.

    为什么是 read 和 a sufficiently small write 呢?

    1 条回复    2021-06-01 17:32:43 +08:00
    AoEiuV020
        1
    AoEiuV020  
       2021-06-01 17:32:43 +08:00
    系统调用忘得差不多了,按我字面上理解,他能保证一次无阻塞的 read,不能保证一次无阻塞的 write,除非 write 内容足够小,
    应该是 read 你无论传多大的 buf 进去,实际有多少内容就会读多少内容,然后直接返回真实读取的字节数不阻塞,
    而 write 不一样,参数 buf 太大的话,一次写不完的话,是会继续阻塞直到全部写完的,
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2881 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 14:00 · PVG 22:00 · LAX 07:00 · JFK 10:00
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.