关于select 函数,网上有很多例子。函数原型是:
int select(int n,fd_set * readfds,fd_set * writefds,fd_set * exceptfds,struct timeval * timeout);
有个参数是 readfds和writefds,我在调用这个函数的时候,两个都是设为非空,结果,运行老是出错,不是想要的结果。
所以在使用select 函数时, 这三个 fd_set 只能一个为非空,。
像这样调用,就得不到想要结果 : select(sockfd, rfds, wfds, NULL, NULL).