[英]Impact of using select with blocking and non-blocking sockets
如果我使用带有select()调用的非阻塞套接字而不是使用带有select()调用的阻塞套接字,我的程序将如何在行为上有所不同?
select
轮询的行为不会有所不同,只有接收/发送功能在阻塞/非阻塞套接字之间会有所不同。
select()
won't behave differently. select()
行为不会有所不同。 read()
, write()
, accept()
and other I/O functions will -- they will never block on non-blocking sockets, while they might block even if select()
tells they would not, although this is somewhat rare. read()
, write()
, accept()
和其他I / O函数将 - 它们永远不会阻塞非阻塞套接字,而它们可能会阻塞, 即使 select()
告诉它们不会,尽管这有点罕见。
https://stackoverflow.com/a/5352634/259543 https://stackoverflow.com/a/5352634/259543
Not sure whether this behavior is allowed by POSIX, though. 但是不确定POSIX是否允许这种行为。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.