u_long has = 1;
ioctl(m_sock, FIONBIO , &has);
这个函数会非常无耻的返回你success,但是它实际上很可能什么也没做。
正确的做法应该是使用fcntl:
int flags = fcntl(m_sock, F_GETFL, 0);
fcntl(m_sock, F_SETFL, flags|O_NONBLOCK);
关于 socke t设置为非阻塞(non-blocking)状态
最新推荐文章于 2023-01-09 13:26:23 发布