将描述符这只为非阻塞:
void setNoBlocking(int fd)
{
int flags = fcntl(fd, F_GETFL, 0);
flags |= O_NONBLOCK;
int res = fcntl(fd, F_SETFL, flags);
if (res < 0)
{
perror("errMsg: setNoBlocking failed");
exit(-1);
}
}
将描述符这只为非阻塞:
void setNoBlocking(int fd)
{
int flags = fcntl(fd, F_GETFL, 0);
flags |= O_NONBLOCK;
int res = fcntl(fd, F_SETFL, flags);
if (res < 0)
{
perror("errMsg: setNoBlocking failed");
exit(-1);
}
}