int readable_timeo(int fd, int sec)
{
fd_set rset;
struct timeval tv;
FD_ZERO(&rset);
FD_SET(fd, &rset);
tv.tv_sec = sec;
tv.tv_usec = 0;
return (select(fd+1, &rset, NULL, NULL, &tv));
}
使用select为recvfrom设置超时
最新推荐文章于 2023-05-16 10:49:26 发布