home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sun-barr!ames!agate!rsoft!mindlink!a3041
- From: Dale_Semchishen@mindlink.bc.ca (Dale Semchishen)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: tcp-ip library nonblocking I/O (Berkeley compatible)?
- Message-ID: <14761@mindlink.bc.ca>
- Date: 1 Sep 92 03:06:59 GMT
- Organization: MIND LINK! - British Columbia, Canada
- Distribution: world
- Lines: 36
-
- > Daniel R. Kegel writes:
- >
- > Questions:
- > 1) Can select() or poll() be used with tcp/ip sockets to detect which of a
- > set of sockets is ready for I/O?
- >
- > 2) Can one use non-blocking I/O on a socket? If so, how?
-
- On Unix systems you can use select() to detect I/O on a socket.
-
- To poll for I/O (ie) no timeout
-
- timeout.tv_sec = 0;
- timeout.tv_usec = 0;
- err = select( max_fd, &read_set, &write_set, &excp_set, &timeout);
-
- To wait for I/O with a 1.5 second timeout
-
- timeout.tv_sec = 1;
- timeout.tv_usec = 500000;
- err = select( max_fd, &read_set, &write_set, &excp_set, &timeout);
-
- To wait forever until I/O arives
-
- err = select( max_fd, &read_set, &write_set, &excp_set, NULL );
-
- Once select returns you then determine which socket has I/O on
- it by using the FD_ISSET() macro
-
- You will have to do some investigation to determine if the
- full functionality of select() has been implemented on the Mac
-
- --
- Dale Semchishen | Internet: Dale_Semchishen@mindlink.bc.ca
- Personal Designs Inc. | tel: (604) 590-0056
- | Vancouver, BC, Canada
-