Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!brl-tgr!tgr!mrose@UDel-Dewey.ARPA From: mrose@UDel-Dewey.ARPA (Marshall Rose) Newsgroups: net.unix-wizards Subject: Re: questions about select and non-blocking I/O Message-ID: <11616@brl-tgr.ARPA> Date: Tue, 16-Jul-85 11:45:27 EDT Article-I.D.: brl-tgr.11616 Posted: Tue Jul 16 11:45:27 1985 Date-Received: Fri, 19-Jul-85 02:07:30 EDT Sender: news@brl-tgr.ARPA Lines: 21 Actually, things are worse off than you think. If you set non-blocking I/O, then select() ALWAYS returns immediately saying that a descriptor can be written. I found this out the hard way: I had a telnet connection which I suspended, even though the remote host was generating output to the network at the time. As soon as all the buffers (network, pty, etc.) had filled up so that the write() from telnetd actually returned EWOULDBLOCK, then telnetd ate the machine alive in a very tight loop: do select() on writing to the network, select() IMMEDIATELY returns, do write() on network, write() fails with EWOULDBLOCK, loop back to select... I fixed the problem by removing the two FIONBIO ioctl()s in telnetd. Now it works "right". Moral of the story: use select() or ioctl(,FIONBIO,), not both for descriptors you want to write(). /mtr