你的位置:首页 > 信息动态 > 新闻中心
信息动态
联系我们

Socket编程

2022/5/16 3:56:20
无阻塞的设置方法

方法一:fcntl
int flag;
if (flag = fcntl(fd, F_GETFL, 0) <0) perror("get flag");
flag |= O_NONBLOCK;
if (fcntl(fd, F_SETFL, flag) < 0)
perror("set flag");

方法二:ioctl

int b_on = 1;
ioctl (fd, FIONBIO, &b_on);