select函数超时问题

int select(int n,fd_set * readfds,fd_set * writefds,fd_set * exceptfds,struct timeval * timeout);
编程出现问题
首先,设置超时时间
struct timeval overtime;
overtime.tv_sec = 2;
overtime.tv_usec = 0;

ret = select(max, &fdset, NULL, NULL, &overtime);

用TCP连接,连接套接字已经加入fdset中,但是运行程序后,在第一个2秒超时后,ret根本不等待超时,
一直不停的返回0.以至于连接上了也无法发送数据。

这是为何??

当将overtime换成NULL后,程序就能正常运行。
ret = select(max, &fdset, NULL, NULL, NULL);

这又是为何?

作者: whyliyi   发布时间: 2011-01-08

哥们儿们,怎么没有哦回答一下呢?

作者: whyliyi   发布时间: 2011-01-08