Xref: utzoo comp.windows.news:324 comp.unix.wizards:6665 Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!elroy!cit-vax!oberon!bloom-beacon!mit-eddie!uw-beaver!ubc-vision!alberta!calgary!radford From: radford@calgary.UUCP (Radford Neal) Newsgroups: comp.windows.news,comp.unix.wizards Subject: Use of select in NeWS. Message-ID: <1376@vaxb.calgary.UUCP> Date: 22 Feb 88 23:18:31 GMT Organization: U. of Calgary, Calgary, Ab. Lines: 25 The portable NeWS source code (1.0) contains the following bit of programming: int readfds, writefds, exceptfds; ... max_fds = getdtablesize(); ... select(max_fds, &readfds, &writefds, &exceptds, timeout); I think it is worth pointing out that this is *WRONG*. The correct approach is to pass 32 as the first parameter of select, maybe via a constant definition. The reason for the first parameter is to specify the size of the bit vectors whose addresses are passed as the 2nd, 3rd, and 4th parameters. These bit vectors are clearly 32 bits in size. The above code will break horribly if UNIX is ever extended to allow more than 32 file descriptors. (Select in this case would be able to take pointers to arrays of ints.) Passing an explicit 32 as the first parameter will continue to work as long as the program isn't actualy using more than 32 files. Radford Neal The University of Calgary