我已阅读有关将套接字设置为非阻塞模式的内容。
http://www.gnu.org/software/libc/manual/html_mono/libc.html#File-Status-Flags
这是我所做的:
static void setnonblocking(int sock)
{
int opts;
opts = fcntl(sock,F_GETFL);
if (opts < 0) {
perror("fcntl(F_GETFL)");
exit(EXIT_FAILURE);
}
opts = (opts | O_NONBLOCK);
if (fcntl(sock,F_SETFL,opts) < 0) {
perror("fcntl(F_SETFL)");
exit(EXIT_FAILURE);
}
return;
}
如何将套接字设置回阻塞模式?我没有看到 O_BLOCK 标志?
谢谢你。