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));
}
int writeable_timeo(int fd, int sec)
{
    fd_set            wset;
    struct timeval    tv;

    FD_ZERO(&rset);
    FD_SET(fd, &rset);

    tv.tv_sec = sec;
    tv.tv_usec = 0;

    return (select(fd+1, NULL, &wset, NULL, &tv));
}

 

相关文章:

  • 2021-12-26
  • 2022-12-23
  • 2021-08-01
  • 2022-01-20
  • 2021-06-08
猜你喜欢
  • 2021-08-11
  • 2022-03-08
  • 2021-06-18
  • 2022-01-24
  • 2021-09-07
相关资源
相似解决方案