【发布时间】:2014-06-24 07:46:17
【问题描述】:
我们使用以下调用设置的非阻塞和异步套接字模式有什么区别。
-
案例 1: int sockfd; // create_sock(sockfd);
// init_sock(sockfd);
fcntl(sockfd, F_SETFL, O_NONBLOCK);
-
案例2:
int sockfd; // create_sock(sockfd);
// init_sock(sockfd);
int on = 1;
ioctl(sockfd, FIOASYNC, &on);
-
案例 3:
int sockfd;
// create_sock(sockfd);
// init_sock(sockfd);
int on = 1; ioctl(sockfd, FIONBIO, &on)
在上述所有情况下,套接字的行为是什么。
谢谢,
【问题讨论】:
标签: sockets asynchronous nonblocking ioctl fcntl