我已经阅读过如何将套接字设置为非阻塞模式。
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 标志?
谢谢。