关于将套接字设置为非阻塞模式,我已经读过这个.
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;
}
Run Code Online (Sandbox Code Playgroud)
如何将套接字设置回阻止模式?我没有看到O_BLOCK标志?
谢谢.