非阻塞IO

设置描述符非阻塞的两种方法:

1,调用 open 时,设置,O_NONBLOCK;

2,调用 fcntl设置;

具体如下:

1,open("/xxx/file1",O_RDWR|O_NONBLOCK);
2,val=fcntl(fd,F_GETFL,0);  F_GETFL获取文件状态标识
     val |=O_NONBLOCK;
     fcntl(fd,F_SETFL,val);  F_SETFL设置文件状态标识
原文地址:https://www.cnblogs.com/jokoz/p/4641041.html