我已閱讀了有關將套接字設置爲非阻塞模式的信息。如何將套接字重置爲阻塞模式(將其設置爲非阻塞模式後)?
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標誌?
謝謝。
看看[這個答案](http://stackoverflow.com/a/18307077/514235)幫助。 – iammilind 2016-05-19 10:54:24