We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
事实上,文档可以做得更好。
该文档假设您已经熟悉套接字 - 这与 POSIX accept 调用,其文档指出,如果它们不是挂起的连接并且您没有明确请求非阻塞操作“accept() 将阻塞直到存在连接”。 (“阻塞”是 UNIX 中对特定类型等待的说法)。
Ruby 类中的非阻塞操作是
accept_nonblock
(根据您链接的文档),因此您可以推断accept
是阻塞的。Ruby 文档由志愿者维护,我相信他们会很乐意接受补丁以使其变得更好。
The truth is, that documentation could be better.
That documentation assumes you're familiar with sockets already—that's a very similar (maybe even identical) behavior to the POSIX accept call, whose documentation states that if they're aren't pending connections and you didn't explicitly request non-blocking operation "accept() shall block until a connection is present". ("Block" is UNIX-speak for a particular type of waiting).
Non-blocking operation in the Ruby class is
accept_nonblock
(according to the document you linked), so you can inferaccept
is blocking.The Ruby documentation is maintained by volunteers, and I'm sure they'd be happy to accept patches to make it better.