writable_timeo.c 447 B

123456789101112131415161718192021222324252627282930
  1. /* include writable_timeo */
  2. #include "unp.h"
  3. int
  4. writable_timeo(int fd, int sec)
  5. {
  6. fd_set wset;
  7. struct timeval tv;
  8. FD_ZERO(&wset);
  9. FD_SET(fd, &wset);
  10. tv.tv_sec = sec;
  11. tv.tv_usec = 0;
  12. return(select(fd+1, NULL, &wset, NULL, &tv));
  13. /* > 0 if descriptor is writable */
  14. }
  15. /* end writable_timeo */
  16. int
  17. Writable_timeo(int fd, int sec)
  18. {
  19. int n;
  20. if ( (n = writable_timeo(fd, sec)) < 0)
  21. err_sys("writable_timeo error");
  22. return(n);
  23. }