home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / mac / programm / 14807 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  1.5 KB

  1. Path: sparky!uunet!sun-barr!ames!agate!rsoft!mindlink!a3041
  2. From: Dale_Semchishen@mindlink.bc.ca (Dale Semchishen)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: tcp-ip library nonblocking I/O (Berkeley compatible)?
  5. Message-ID: <14761@mindlink.bc.ca>
  6. Date: 1 Sep 92 03:06:59 GMT
  7. Organization: MIND LINK! - British Columbia, Canada
  8. Distribution: world
  9. Lines: 36
  10.  
  11. > Daniel R. Kegel writes:
  12. > Questions:
  13. > 1) Can select() or poll() be used with tcp/ip sockets to detect which of a
  14. >     set of sockets is ready for I/O?
  15. > 2) Can one use non-blocking I/O on a socket?    If so, how?
  16.  
  17. On Unix systems you can use select() to detect I/O on a socket.
  18.  
  19. To poll for I/O (ie) no timeout
  20.  
  21.         timeout.tv_sec = 0;
  22.         timeout.tv_usec = 0;
  23.         err = select( max_fd, &read_set, &write_set, &excp_set, &timeout);
  24.  
  25. To wait for I/O with a 1.5 second timeout
  26.  
  27.         timeout.tv_sec = 1;
  28.         timeout.tv_usec = 500000;
  29.         err = select( max_fd, &read_set, &write_set, &excp_set, &timeout);
  30.  
  31. To wait forever until I/O arives
  32.  
  33.         err = select( max_fd, &read_set, &write_set, &excp_set, NULL );
  34.  
  35. Once select returns you then determine which socket has I/O on
  36. it by using the FD_ISSET() macro
  37.  
  38. You will have to do some investigation to determine if the
  39. full functionality of select() has been implemented on the Mac
  40.  
  41. --
  42. Dale Semchishen              | Internet: Dale_Semchishen@mindlink.bc.ca
  43. Personal Designs Inc.        | tel: (604) 590-0056
  44.                              | Vancouver, BC, Canada
  45.